servant icon indicating copy to clipboard operation
servant copied to clipboard

return an `MonadUnliftIO m => ApplicationT m` from `serve`

Open MangoIV opened this issue 1 year ago • 1 comments

This would be useful to provide alternative handlers for effects that are accessed by all handlers in a server; e.g. say we have a Logging effect with some lock, we don't want to have this per handler buy ideally per application, currently that's not possible because the hoist function in the available APIs goes to Handler a; I would like something like:

genericServeTT
  :: forall routes m n.
       ( {- snip -}
       , MonadUnliftIO n
       )
    => (forall a. m a -> ExceptT ServerError n a)
    -> routes (AsServerT m)
    -> ApplicationT n

does that make sense?

Thanks in advance!

MangoIV avatar Mar 17 '24 12:03 MangoIV

possibly related: https://github.com/haskell-servant/servant/issues/1544

It would basically be similar to RawM except it would not be on a per route basis.

MangoIV avatar Mar 17 '24 12:03 MangoIV