Safe Haskell | None |
---|---|
Language | Haskell2010 |
Core.Webserver.Servant
Description
Support integrating web services created by servant with handlers defined
in the Program
monad. This is a thin wrapper which creates an Application
which can be used with launchWebserver
.
import Core.Program import Core.Webserver.Servant import Core.Webserver.Warp import MyServer (api, routes) main ::IO
() main = doexecute
$ do application <-prepareRoutes
api routeslaunchWebserver
8080 application
Synopsis
- prepareRoutes :: forall τ (api :: Type). HasServer api '[] => Proxy api -> ServerT api (Program τ) -> Program τ Application
- prepareRoutesWithContext :: forall τ (api :: Type) context. (HasServer api context, ServerContext context) => Proxy api -> Context context -> ServerT api (Program τ) -> Program τ Application
Documentation
prepareRoutes :: forall τ (api :: Type). HasServer api '[] => Proxy api -> ServerT api (Program τ) -> Program τ Application Source #
Convert a servant API and set of handlers into a warp Application
.
This Application
must be used with launchWebserver
so
that the necessary internal connections are made.
Usage is straight forward:
application <-prepareRoutes
api routeslaunchWebserver
8080 application
This code creates an Application which has sufficient information to unlift
back to the Program
monad so that your handlers can be take advantage of the
logging and telemetry facilities of core-program and core-telemetry.
prepareRoutesWithContext :: forall τ (api :: Type) context. (HasServer api context, ServerContext context) => Proxy api -> Context context -> ServerT api (Program τ) -> Program τ Application Source #
Prepare routes as with prepareRoutes
above, but providing a servant
Context
in order to give detailed control of the setup.
Since: 0.1.1