servant-snap-0.8.3.2: A family of combinators for defining webservices APIs and serving them

Safe HaskellNone
LanguageHaskell2010

Servant.Server.Internal.Router

Synopsis

Documentation

type Router (m :: * -> *) env = Router' m env (RoutingApplication m) Source #

data Router' (m :: * -> *) env a Source #

Internal representation of a router.

Constructors

StaticRouter (Map Text (Router' m env a)) [env -> a] 
CaptureRouter (Router' m (Text, env) a) 
CaptureAllRouter (Router' m ([Text], env) a) 
RawRouter (env -> a) 
Choice (Router' m env a) (Router' m env a) 
Instances
Functor (Router' m env) Source # 
Instance details

Defined in Servant.Server.Internal.Router

Methods

fmap :: (a -> b) -> Router' m env a -> Router' m env b #

(<$) :: a -> Router' m env b -> Router' m env a #

pathRouter :: Text -> Router' m env a -> Router' m env a Source #

leafRouter :: (env -> a) -> Router' m env a Source #

choice :: MonadSnap m => Router' m env a -> Router' m env a -> Router' m env a 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.

sameStructure :: Router' m env a -> Router' m env b -> Bool Source #

Compare the structure of two routers.

routerLayout :: Router' m env a -> Text Source #

Provide a textual representation of the structure of a router.

tweakResponse :: (RouteResult Response -> RouteResult Response) -> Router m env -> Router m env Source #

Apply a transformation to the response of a Router.

runRouterEnv :: MonadSnap m => Router m env -> env -> RoutingApplication m Source #

Interpret a router as an application.