core-webserver-servant-0.1.1.1: Interoperability with Servant
Safe HaskellNone
LanguageHaskell2010

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 = do
    execute $ do
        application <- prepareRoutes api routes
        launchWebserver 8080 application
Synopsis

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 routes
        launchWebserver 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