Safe Haskell | None |
---|---|
Language | Haskell2010 |
Defines convenience functions to run a servant base api in wrap server
Synopsis
- chakraApp :: forall β χ ψ. (HasServer χ ψ, HasContextEntry (ψ .++ DefaultErrorFormatters) ErrorFormatters) => Context ψ -> β -> Proxy χ -> ServerT χ (RIO β) -> Application
- runChakraApp :: (MonadIO m, HasServer χ ψ, HasContextEntry (ψ .++ DefaultErrorFormatters) ErrorFormatters) => Middleware -> Context ψ -> β -> Proxy χ -> ServerT χ (RIO β) -> m ()
- runChakraAppWithMetrics :: (MonadIO m, HasServer χ ψ, HasContextEntry (ψ .++ DefaultErrorFormatters) ErrorFormatters) => Middleware -> Context ψ -> β -> Proxy χ -> ServerT χ (RIO β) -> m ()
- chakraMiddlewares :: InfoDetail -> IO Middleware
- registerMetrics :: MonadIO m => m GHCMetrics
- chakraErrorFormatters :: ErrorFormatters
- runChakraHandler :: a -> RIO a h -> Handler h
Documentation
:: forall β χ ψ. (HasServer χ ψ, HasContextEntry (ψ .++ DefaultErrorFormatters) ErrorFormatters) | |
=> Context ψ | Servant Context e.g., EmptyContext |
-> β | Application Has stacking in tuple type e.g., (ModLogger,ModHttpClient,UserRepo) |
-> Proxy χ | Servant API Proxy |
-> ServerT χ (RIO β) | Servant api handlers in `RIO β` monad |
-> Application | Returns WAI compatiable Application so you can run using wrap |
Setup servant with custom context so that the handers can take custom effects/ctx
:: (MonadIO m, HasServer χ ψ, HasContextEntry (ψ .++ DefaultErrorFormatters) ErrorFormatters) | |
=> Middleware | WAI based middlewares |
-> Context ψ | Servant Context e.g., EmptyContext |
-> β | Application Has stacking in tuple type e.g., (ModLogger,ModHttpClient,UserRepo) |
-> Proxy χ | Servant API Proxy |
-> ServerT χ (RIO β) | Servant api handlers in `RIO β` monad |
-> m () |
Starts the warp server with given middlewares, context, api definition and api server Does not enable/registers GHC internal metrics
runChakraAppWithMetrics Source #
:: (MonadIO m, HasServer χ ψ, HasContextEntry (ψ .++ DefaultErrorFormatters) ErrorFormatters) | |
=> Middleware | WAI based middlewares |
-> Context ψ | Servant Context e.g., EmptyContext |
-> β | Application Has stacking in tuple type e.g., (ModLogger,ModHttpClient,UserRepo) |
-> Proxy χ | Servant API Proxy |
-> ServerT χ (RIO β) | Servant api handlers in `RIO β` monad |
-> m () |
Starts the warp server with given middlewares, context, api definition and api server Enables prometheus metrics (with GHC internal metrics) (Needs -with-rtsopts=-T)
chakraMiddlewares :: InfoDetail -> IO Middleware Source #
Return default set of middlewares applied
registerMetrics :: MonadIO m => m GHCMetrics Source #
Registers GHC runtime metrics so that /metrics endpoint will return rich GHC info Requires `-with-rtsopts=-T`
chakraErrorFormatters :: ErrorFormatters Source #
Custom Servant Error formatter overrides to return in JSON format
runChakraHandler :: a -> RIO a h -> Handler h Source #
Natural transformation to run handlers in RIO monad instead of ServantT