Copyright | (c) Raghu Kaippully 2020 |
---|---|
License | MPL-2.0 |
Maintainer | rkaippully@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Types and functions to route HTTP requests.
Synopsis
- type RouterT m = ExceptT (Maybe (First (Response ByteString))) m
- class (Alternative m, MonadPlus m) => MonadRouter m where
- rejectRoute :: m a
- failHandler :: Response ByteString -> m a
- runRoute :: Monad m => Handler (RouterT m) '[] res ByteString -> Request -> m Response
Documentation
type RouterT m = ExceptT (Maybe (First (Response ByteString))) m Source #
The monad transformer stack for routing.
- The
ExceptT
provides short-circuiting behaviour forrejectRoute
andfailHandler
. - In case of
rejectRoute
, aNothing
value is returned and in case offailHandler
, aResponse ByteString
is returned. - The
First
wrapper is provided to get instances ofAlternative
andMonadPlus
forRouterT
.
class (Alternative m, MonadPlus m) => MonadRouter m where Source #
HTTP request routing with short circuiting behavior.
rejectRoute :: m a Source #
Mark the current route as rejected, alternatives can be tried
failHandler :: Response ByteString -> m a Source #
Short-circuit the current handler and return a response
Instances
Monad m => MonadRouter (RouterT m) Source # | |
Defined in WebGear.Route rejectRoute :: RouterT m a Source # failHandler :: Response ByteString -> RouterT m a Source # |
runRoute :: Monad m => Handler (RouterT m) '[] res ByteString -> Request -> m Response Source #
Convert a routable handler into a plain function.
This function is typically used to convert WebGear routes to a
Application
.