snap-predicates-0.3.1: Declarative routing for Snap.

Safe HaskellNone

Snap.Predicate.Header

Synopsis

Documentation

data Header a Source

The most generic request header predicate provided. It will get all request header values of _name and pass them on to the conversion function _read, which might either yield an error message or a value. If the header 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

Header 

Fields

_hdrName :: !ByteString

request header name

_hdrRead :: [ByteString] -> Either ByteString a

conversion function

_hdrDefault :: !(Maybe a)

(optional) default value

Instances

data Hdr a Source

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

Constructors

Hdr ByteString 

Instances

data HdrOpt a Source

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

Constructors

HdrOpt ByteString 

Instances

data HdrDef a Source

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

Constructors

HdrDef ByteString a 

Instances

data HasHdr Source

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

Constructors

HasHdr ByteString