wai-routing-0.3.1: 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

type Renderer = Error -> Maybe ByteStringSource

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

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

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

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

Run the Routes monad and return the handlers per path.

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

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

addRouteSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> Method 
-> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

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

getSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

headSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

postSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

putSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

deleteSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

traceSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

optionsSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

connectSource

Arguments

:: (Monad m, Predicate p Req, FVal p ~ Error) 
=> ByteString

path

-> (TVal p -> m Response)

handler

-> p

Predicate

-> Routes a m () 

Specialisation of addRoute for a specific HTTP Method.

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.