Safe Haskell | None |
---|---|
Language | Haskell2010 |
WebGear.Core.Handler
Description
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
Methods
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
Constructors
RouteMismatch |
Instances
newtype Description Source #
Description associated with part of an API
Constructors
Description | |
Fields |
Instances
Eq Description Source # | |
Defined in WebGear.Core.Handler | |
Ord Description Source # | |
Defined in WebGear.Core.Handler Methods compare :: Description -> Description -> Ordering # (<) :: Description -> Description -> Bool # (<=) :: Description -> Description -> Bool # (>) :: Description -> Description -> Bool # (>=) :: Description -> Description -> Bool # max :: Description -> Description -> Description # min :: Description -> Description -> Description # | |
Read Description Source # | |
Defined in WebGear.Core.Handler Methods readsPrec :: Int -> ReadS Description # readList :: ReadS [Description] # readPrec :: ReadPrec Description # readListPrec :: ReadPrec [Description] # | |
Show Description Source # | |
Defined in WebGear.Core.Handler Methods showsPrec :: Int -> Description -> ShowS # show :: Description -> String # showList :: [Description] -> ShowS # | |
IsString Description Source # | |
Defined in WebGear.Core.Handler Methods fromString :: String -> Description # |
A summary associated with part of an API
Constructors
Summary | |
Fields
|
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.