Saturn Router – same function for getf and get?

The get combinator expects a second parameter of type HttpHandler. This is it in your code:

get "/order" (warbler (fun (_, ctx) -> PageController.loadScreen ctx 0))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                         /
                                This is an HttpHandler value

getf, on the other hand, expects a different second parameter. It expects a function that takes an int as a parameter and returns a HttpHandler as a result.

So just stick fun number -> in front of your existing HttpHandler, and voila:

getf "/order/%i" (fun number -> 
  (warbler (fun (_, ctx) -> PageController.loadScreen ctx number))
)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top