chakra-0.1.0: A REST Web Api server template for building (micro)services.
Safe HaskellNone
LanguageHaskell2010

Chakra.App

Description

Defines convenience functions to run a servant base api in wrap server

Synopsis

Documentation

chakraApp Source #

Arguments

:: 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

runChakraApp Source #

Arguments

:: (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 #

Arguments

:: (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