Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
WebGear handlers
Synopsis
- class (ArrowChoice h, ArrowPlus h, ArrowError RouteMismatch h, Monad m) => Handler h m | h -> m where
- arrM :: (a -> m b) -> h a b
- consumeRoute :: h RoutePath a -> h () a
- setDescription :: Description -> h a a
- setSummary :: Summary -> h a a
- newtype RoutePath = RoutePath [Text]
- data RouteMismatch = RouteMismatch
- newtype Description = Description {}
- newtype Summary = Summary {
- getSummary :: Text
- type RequestHandler h req = h (Linked req Request) Response
- type Middleware h reqOut reqIn = RequestHandler h reqIn -> RequestHandler h reqOut
- routeMismatch :: ArrowError RouteMismatch h => h a b
- unlinkA :: Handler h m => h (Linked ts Response) Response
Documentation
class (ArrowChoice h, ArrowPlus h, ArrowError RouteMismatch h, Monad m) => Handler h m | h -> m where Source #
A handler is an arrow with a monadic context.
Handlers have the following capabilities:
- Lift a monadic action into a handler arrow.
- Implement
ArrowChoice
typeclass so that conditionals can be used in arrow code. - Implement
ArrowPlus
for routing requests to specific handlers. - Provide contextual documentation elements - description and summary
arrM :: (a -> m b) -> h a b Source #
Lift a monadic function to a handler arrow
consumeRoute :: h RoutePath a -> h () a Source #
Consume all remaining path components with an arrow
setDescription :: Description -> h a a Source #
Set a description of a part of an API
setSummary :: Summary -> h a a Source #
Set a summary of a part of an API
Parts of the request path used by the routing machinery
data RouteMismatch Source #
Indicates that a handler cannot process this route
Instances
newtype Description Source #
Description associated with part of an API
Instances
A summary associated with part of an API
type RequestHandler h req = h (Linked req Request) Response Source #
A handler arrow from a linked request to response.
type Middleware h reqOut reqIn = RequestHandler h reqIn -> RequestHandler h reqOut Source #
A middleware enhances a RequestHandler
and produces another handler.
routeMismatch :: ArrowError RouteMismatch h => h a b Source #
Indicates that the request does not match the current handler.