let apiRouter = router {
pipe_through browser //Sets a HttpContext accessible by controller functions
not_found_handler (setStatusCode 404 >=> text "404")
get "/" (PageController.loadHomePage())
getf "/about/%i" (PageController.loadAboutPage)
}
Where loadHomePage() returns a htmlString
However the function does depend on side effects (namely cookies) which is currently accessed through a mutable HttpContext that is set in the browser pipeline.
In my use case, I do not want loadHomePage to be executed at compile time, only when "/" is accessed, else it will generate an error as the HttpContext it's trying to access won't be set. Since this isn't a very functional way of doing things, I'm perfectly happy to pass a context from the router to the function but I cannot figure out how to do it.
I have a router set up, a la
Where loadHomePage() returns a
htmlString
However the function does depend on side effects (namely cookies) which is currently accessed through a mutable HttpContext that is set in the browser pipeline.
In my use case, I do not want loadHomePage to be executed at compile time, only when "/" is accessed, else it will generate an error as the HttpContext it's trying to access won't be set. Since this isn't a very functional way of doing things, I'm perfectly happy to pass a context from the router to the function but I cannot figure out how to do it.
Thank you