respond-1.0.0: process and route HTTP requests and generate responses on top of WAI

Safe HaskellNone
LanguageHaskell2010

Web.Respond.Method

Contents

Description

contains MethodMatcher and associated tools for routing based on the HTTP request method.

Synopsis

Documentation

newtype MethodMatcher a Source

Map from method to thing. use it as a monoid.

onGET action1 <> onPUT action2

Constructors

MethodMatcher 

Instances

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.

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