| Copyright | (c) Raghu Kaippully 2020 |
|---|---|
| License | MPL-2.0 |
| Maintainer | rkaippully@gmail.com |
| Safe Haskell | None |
| Language | Haskell2010 |
WebGear.Route
Description
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
ExceptTprovides short-circuiting behaviour forrejectRouteandfailHandler. - In case of
rejectRoute, aNothingvalue is returned and in case offailHandler, aResponse ByteStringis returned. - The
Firstwrapper is provided to get instances ofAlternativeandMonadPlusforRouterT.
class (Alternative m, MonadPlus m) => MonadRouter m where Source #
HTTP request routing with short circuiting behavior.
Methods
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 Methods 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.