snap-predicates-0.2.0: Declarative routing for Snap.

Safe HaskellNone

Snap.Predicates.Params

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. In case of error, 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

_name :: !ByteString

request parameter name

_read :: [ByteString] -> Either ByteString a

conversion function

_default :: !(Maybe a)

(optional) default value

data Param a Source

Specialisation of Parameter which returns the first request which could be converted to the target type.

Constructors

Param ByteString 

Instances

data ParamOpt a Source

Like Param, but denoting an optional parameter, i.e. if the parameter is not present or can not be converted to the target type, the predicate will still succeed.

Constructors

ParamOpt ByteString 

Instances

data ParamDef a Source

Like Param, but in case the parameter could not be found, the provided default value will be used. ParamDef is provided for convenience and nothing else than Param || Const, e.g. ParamDef "foo" 0 == Param "foo" :|: Const 0.

Constructors

ParamDef ByteString a 

Instances