My webserver is written in an AppM :: ReaderT Env IO
monad. The Env
type, for the purpose of centralized auditing code, needs to know the request's path. Therefore, my hoistServer
usage looks something like this:
\req respHandler ->
let application = serve apiProxy $ hoistServer apiProxy (\appm -> runAppM req appm) myServer
in application req respHandler
Notice how the second argument to hoistServer
depends on the incoming req
.
What are the performance implications of doing something like this? Is the servant application going to get "re-created" for every incoming request?
Is there any other way to possibly write this code to make it more performant?