I have defined some routes, and I'd like to fall through to serving static content if none of those routes match. Form the docs, it looks like the answer is
type Routes = MyRoutes :<|> ... :<|> Raw
handlers = myRoutes :<|> ... :<|> serveDirectory "some-directory"
However, this does not work when I have also used a custom Monad, and so my main method looks a little like:
let handlers = enter (appToHandler appState) routes let context = hasSessionHandler appState :. isAdminHandler appState :. EmptyContext
let server = serveWithContext (Proxy :: Proxy Routes) context handlers
run 8080 server
It turns out that this is referenced in several Github issues for Servant stretching back a while, but it looks like no solution has been agreed upon.
So my question is; what is the standard approach to serving a directory of static files alongside my servant routes when I use a custom monad?
The only approach that comes to mind so far is to not use a custom monad, and instead thread my state through to each route and jump into a custom monad per-route instead. I'd love to hear if there is a better approach!
--