Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Router (m :: * -> *) env = Router' m env (RoutingApplication m)
- data Router' (m :: * -> *) env a
- = 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)
- pathRouter :: Text -> Router' m env a -> Router' m env a
- leafRouter :: (env -> a) -> Router' m env a
- choice :: MonadSnap m => Router' m env a -> Router' m env a -> Router' m env a
- data RouterStructure
- routerStructure :: Router' m env a -> RouterStructure
- sameStructure :: Router' m env a -> Router' m env b -> Bool
- routerLayout :: Router' m env a -> Text
- tweakResponse :: (RouteResult Response -> RouteResult Response) -> Router m env -> Router m env
- runRouter :: MonadSnap m => Router m () -> RoutingApplication m
- runRouterEnv :: MonadSnap m => Router m env -> env -> RoutingApplication m
- runChoice :: [env -> RoutingApplication m] -> env -> RoutingApplication m
- worseHTTPCode :: Int -> Int -> Bool
Documentation
type Router (m :: * -> *) env = Router' m env (RoutingApplication m) Source #
data Router' (m :: * -> *) env a Source #
Internal representation of a router.
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) |
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.
data RouterStructure Source #
StaticRouterStructure (Map Text RouterStructure) Int | |
CaptureRouterStructure RouterStructure | |
RawRouterStructure | |
ChoiceStructure RouterStructure RouterStructure |
Instances
Eq RouterStructure Source # | |
Defined in Servant.Server.Internal.Router (==) :: RouterStructure -> RouterStructure -> Bool # (/=) :: RouterStructure -> RouterStructure -> Bool # | |
Show RouterStructure Source # | |
Defined in Servant.Server.Internal.Router showsPrec :: Int -> RouterStructure -> ShowS # show :: RouterStructure -> String # showList :: [RouterStructure] -> ShowS # |
routerStructure :: Router' m env a -> RouterStructure Source #
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.
runChoice :: [env -> RoutingApplication m] -> env -> RoutingApplication m Source #