Skip to content

why do you need to explicitly return an HttpHandler when you need the HttpContext? #475

Answered by dustinmoris
Melomaniash asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, great question and the answer is that there is no difference.

However, there are two reasons which I can think of why some people prefer the first case:

  1. You can annotate the return type to be HttpHandler and then let the linter and compiler help you to put the curried parameters in the correct order and make sure that the return type matches what a HttpHandler expects. It's a facility to help write correct code.
  2. If you have more curried arguments before the next and ctx then you could run some work in advance before the HttpHandler part is being returned.

Example:

let addExampleRecord (foo : string) (bar : int) =
        // Do some work only once here using foo and bar
        let f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Melomaniash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants