SaturnFramework / Saturn

Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
https://saturnframework.org
MIT License
714 stars 108 forks source link

Information required: error_handler in Saturn template router CE #165

Closed reflash closed 5 years ago

reflash commented 5 years ago

Hi!

I was trying to run Saturn template and create some sample APIs with it. In the template the commented section contains this apiRouter, which I tried to modify:

let apiRouter = router {
    error_handler (text "Api 404")
    pipe_through api

    get "/hello" (text "Hello")
}

It fails with the error_handler function and I don't see it being in any documentation about Router. Is it still relevant code?

reflash commented 5 years ago

And also in the same sample it seems plug acceptJson fails all of my requests. I'm not entirely sure about how it works, so if you could, clarify it, please.

UPD: For this one I found out that the client should accept json mime type. acceptHtml should probably allow to accept requests from web browser either.

vtquan commented 5 years ago

As for the first issue, I encountered the same issue and noticed that not_found_handler (setStatusCode 404 >=> text "Api 404") is used in the samples and that is what I have been using instead. Definitely should be updated in the documentation as well.

reflash commented 5 years ago

Documentation was updated in the merged PR. Closing the issue