wai-routing-0.8: Declarative routing for WAI.

Safe HaskellNone
LanguageHaskell2010

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

data Meta a Source

Data added to a route via attach is returned in this Meta record.

Constructors

Meta 

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 Response Source

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

addRoute Source

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 -> [Meta a] Source

Get back all attached metadata.

get Source

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.

head Source

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.

post Source

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.

put Source

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.

delete Source

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.

trace Source

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.

options Source

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.

connect Source

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.

patch Source

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 ByteString Source

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.