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

Safe HaskellNone
LanguageHaskell2010

Servant.Server.Internal.Router

Synopsis

Documentation

data Router' a Source

Internal representation of a router.

Constructors

WithRequest (Request -> Router)

current request is passed to the router

StaticRouter (Map Text Router)

first path component used for lookup and removed afterwards

DynamicRouter (Text -> Router)

first path component used for lookup and removed afterwards

LeafRouter a

to be used for routes that match an empty path

Choice Router Router

left-biased choice between two routers

tweakResponse :: (RouteResult Response -> RouteResult Response) -> Router -> Router Source

Apply a transformation to the response of a Router.

choice :: Router -> Router -> Router Source

Smart constructor for the choice between routers. We currently optimize the following cases:

  • Two static routers can be joined by joining their maps.
  • Two dynamic routers can be joined by joining their codomains.
  • Two WithRequest routers can be joined by passing them the same request and joining their codomains.
  • A WithRequest router can be joined with anything else by passing the same request to both but ignoring it in the component that does not need it.

runRouter :: Router -> RoutingApplication Source

Interpret a router as an application.