servant-server-0.20: A family of combinators for defining webservices APIs and serving them

Safe Haskell | Safe-Inferred
Language | Haskell2010

Servant.Server.Generic

Description

Since: 0.14.1

Synopsis

- data AsServerT (m :: * -> *)
- type AsServer = AsServerT Handler
- genericServe :: forall routes. (HasServer (ToServantApi routes) '[], GenericServant routes AsServer, Server (ToServantApi routes) ~ ToServant routes AsServer) => routes AsServer -> Application
- genericServeT :: forall (routes :: * -> *) (m :: * -> *). (GenericServant routes (AsServerT m), GenericServant routes AsApi, HasServer (ToServantApi routes) '[], ServerT (ToServantApi routes) m ~ ToServant routes (AsServerT m)) => (forall a. m a -> Handler a) -> routes (AsServerT m) -> Application
- genericServeTWithContext :: forall (routes :: * -> *) (m :: * -> *) (ctx :: [*]). (GenericServant routes (AsServerT m), GenericServant routes AsApi, HasServer (ToServantApi routes) ctx, HasContextEntry (ctx .++ DefaultErrorFormatters) ErrorFormatters, ServerT (ToServantApi routes) m ~ ToServant routes (AsServerT m)) => (forall a. m a -> Handler a) -> routes (AsServerT m) -> Context ctx -> Application
- genericServer :: GenericServant routes AsServer => routes AsServer -> ToServant routes AsServer
- genericServerT :: GenericServant routes (AsServerT m) => routes (AsServerT m) -> ToServant routes (AsServerT m)

# Documentation

data AsServerT (m :: * -> *) #

A type that specifies that an API record contains a server implementation.

#### Instances

Instances details

GenericMode (AsServerT m) # |
Instance details Defined in Servant.Server.Internal Associated Types type (AsServerT m) :- api #
type (AsServerT m) :- api # |
Instance details Defined in Servant.Server.Internal type (AsServerT m) :- api = ServerT api m

type AsServer = AsServerT Handler #

genericServe :: forall routes. (HasServer (ToServantApi routes) '[], GenericServant routes AsServer, Server (ToServantApi routes) ~ ToServant routes AsServer) => routes AsServer -> Application #

Transform a record of routes into a WAI `Application`.

genericServeT #

Arguments

:: forall (routes :: * -> *) (m :: * -> *). (GenericServant routes (AsServerT m), GenericServant routes AsApi, HasServer (ToServantApi routes) '[], ServerT (ToServantApi routes) m ~ ToServant routes (AsServerT m)) |
=> (forall a. m a -> Handler a) | `hoistServer` argument to come back to `Handler`
-> routes (AsServerT m) | your record full of request handlers
-> Application |

Transform a record of routes with custom monad into a WAI `Application`, by providing a transformation to bring each handler back in the `Handler` monad.

genericServeTWithContext #

Arguments

:: forall (routes :: * -> *) (m :: * -> *) (ctx :: [*]). (GenericServant routes (AsServerT m), GenericServant routes AsApi, HasServer (ToServantApi routes) ctx, HasContextEntry (ctx .++ DefaultErrorFormatters) ErrorFormatters, ServerT (ToServantApi routes) m ~ ToServant routes (AsServerT m)) |
=> (forall a. m a -> Handler a) | `hoistServer` argument to come back to `Handler`
-> routes (AsServerT m) | your record full of request handlers
-> Context ctx | the `Context` to serve the application with
-> Application |

Transform a record of routes with custom monad into a WAI `Application`, while using the given `Context` to serve the application (contexts are typically used by auth-related combinators in servant, e.g to hold auth checks) and the given transformation to map all the handlers back to the `Handler` monad.

genericServer :: GenericServant routes AsServer => routes AsServer -> ToServant routes AsServer #

Transform a record of endpoints into a `Server`.

genericServerT :: GenericServant routes (AsServerT m) => routes (AsServerT m) -> ToServant routes (AsServerT m) #

Transform a record of endpoints into a ``ServerT` m`.

You can see an example usage of this function in the Servant Cookbook.