wai-routing-0.4: Declarative routing for WAI.

Safe HaskellNone

Network.Wai.Routing.Route

Synopsis

Documentation

data Routes a m b Source

The Routes monad is used to add routing declarations via addRoute or one of get, post, etc.

Instances

prepare :: Monad m => Routes a m b -> [(ByteString, RoutingReq -> m Response)]Source

Run the Routes monad and return the handlers per path.

route :: Monad m => [(ByteString, RoutingReq -> m Response)] -> Request -> m ResponseSource

A WAI Application (generalised from IO to Monad) which routes requests to handlers based on predicated route declarations.

addRouteSource

Arguments

:: Monad m 
=> Method 
-> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Add a route for some Method and path (potentially with variable captures) and constrained by some Predicate.

attach :: a -> Routes a m ()Source

Add some metadata to the last route.

examine :: Routes a m b -> [a]Source

Get back all attached metadata.

getSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

headSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

postSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

putSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

deleteSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

traceSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

optionsSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

connectSource

Arguments

:: Monad m 
=> ByteString

path

-> (a -> m Response)

handler

-> Predicate RoutingReq Error a

Predicate

-> Routes b m () 

Specialisation of addRoute for a specific HTTP Method.

type Renderer = Error -> Maybe ByteStringSource

Function to turn an Error value into a ByteString. Clients can provide their own renderer using renderer.

renderer :: Renderer -> Routes a m ()Source

Set a custom render function, i.e. a function to turn Errors into ByteStrings.