snap-predicates-0.3.1: Declarative routing for Snap.

Safe HaskellNone

Snap.Predicate.Param

Synopsis

Documentation

data Parameter a Source

The most generic request parameter predicate provided. It will get all request parameter values of _name and pass them on to the conversion function _read, which might either yield an error message or a value. If the parameter is not present, an optional default may be returned instead, if nothing is provided, the error message will be used when construction the 400 status.

Constructors

Parameter 

Fields

_pName :: !ByteString

request parameter name

_pRead :: [ByteString] -> Either ByteString a

conversion function

_pDefault :: !(Maybe a)

(optional) default value

data Param a Source

Specialisation of Parameter which returns the first request parameter which could be converted to the target type. Relies on Readable type-class for the actual conversion.

Constructors

Param ByteString 

Instances

data ParamOpt a Source

Predicate which returns the first request parameter which could be converted to the target type wrapped in a Maybe. If the parameter is not present, Nothing will be returned. Relies on Readable type-class for the actual conversion.

Constructors

ParamOpt ByteString 

Instances

data ParamDef a Source

Specialisation of Parameter which returns the first request parameter which could be converted to the target type. If the parameter is not present, the provided default will be used. Relies on Readable type-class for the actual conversion.

Constructors

ParamDef ByteString a 

Instances

data HasParam Source

Predicate which is true if the request has a parameter with the given name.

Constructors

HasParam ByteString