Safe Haskell | None |
---|---|
Language | Haskell2010 |
contains MethodMatcher and associated tools for routing based on the HTTP request method.
- newtype MethodMatcher a = MethodMatcher {
- getMethodMatcher :: Map StdMethod a
- matchMethod :: MonadRespond m => MethodMatcher (m ResponseReceived) -> m ResponseReceived
- onMethod :: StdMethod -> a -> MethodMatcher a
- onGET :: a -> MethodMatcher a
- onPOST :: a -> MethodMatcher a
- onHEAD :: a -> MethodMatcher a
- onPUT :: a -> MethodMatcher a
- onDELETE :: a -> MethodMatcher a
- onTRACE :: a -> MethodMatcher a
- onCONNECT :: a -> MethodMatcher a
- onOPTIONS :: a -> MethodMatcher a
- onPATCH :: a -> MethodMatcher a
- matchOnlyMethod :: MonadRespond m => StdMethod -> m ResponseReceived -> m ResponseReceived
- matchGET :: MonadRespond m => m ResponseReceived -> m ResponseReceived
Documentation
newtype MethodMatcher a Source
Map from method to thing. use it as a monoid.
onGET action1 <> onPUT action2
Monoid (MethodMatcher a) |
using the method matcher
matchMethod :: MonadRespond m => MethodMatcher (m ResponseReceived) -> m ResponseReceived Source
look up the request method in the MethodMatcher map and run the
action; fall back on handleUnsupportedMethod
if the method cannot be
parsed or is not in the map.
prebuilt method matchers
onMethod :: StdMethod -> a -> MethodMatcher a Source
map a StdMethod to a thing.
onGET :: a -> MethodMatcher a Source
onPOST :: a -> MethodMatcher a Source
onHEAD :: a -> MethodMatcher a Source
onPUT :: a -> MethodMatcher a Source
onDELETE :: a -> MethodMatcher a Source
onTRACE :: a -> MethodMatcher a Source
onCONNECT :: a -> MethodMatcher a Source
onOPTIONS :: a -> MethodMatcher a Source
onPATCH :: a -> MethodMatcher a Source
method matching shortcuts
matchOnlyMethod :: MonadRespond m => StdMethod -> m ResponseReceived -> m ResponseReceived Source
shortcut for when you want to run an inner action for just one http method
matchOnlyMethod m = matchMethod . onMethod m
matchGET :: MonadRespond m => m ResponseReceived -> m ResponseReceived Source
shortcut for matchOnlyMethod
GET