servant-0.8.1: A family of combinators for defining webservices APIs

Safe HaskellNone
LanguageHaskell2010

Servant.API.ResponseHeaders

Description

This module provides facilities for adding headers to a response.

>>> let headerVal = addHeader "some-url" 5 :: Headers '[Header "Location" String] Int

The value is added to the header specified by the type (Location in the example above).

Synopsis

Documentation

data Headers ls a Source #

Response Header objects. You should never need to construct one directly. Instead, use addHeader.

Constructors

Headers 

Fields

Instances

(KnownSymbol h, ToByteString v) => AddHeader Symbol h v (Headers ((:) * fst rest) a) (Headers ((:) * (Header h v) ((:) * fst rest)) a) Source # 

Methods

addHeader :: Headers ((* ': fst) rest) a -> Headers ((* ': Header h v) ((* ': fst) rest)) a -> new Source #

Functor (Headers ls) Source # 

Methods

fmap :: (a -> b) -> Headers ls a -> Headers ls b #

(<$) :: a -> Headers ls b -> Headers ls a #

(KnownSymbol h, GetHeaders (HList rest), ToByteString v) => GetHeaders (Headers ((:) * (Header h v) rest) a) Source # 

Methods

getHeaders :: Headers ((* ': Header h v) rest) a -> [Header] Source #

GetHeaders (Headers ([] *) a) Source # 

Methods

getHeaders :: Headers [*] a -> [Header] Source #

class AddHeader h v orig new | h v orig -> new, new -> h, new -> v, new -> orig where Source #

Minimal complete definition

addHeader

Methods

addHeader :: v -> orig -> new Source #

Instances

(KnownSymbol h, ToByteString v, (~) * new (Headers ((:) * (Header h v) ([] *)) a)) => AddHeader Symbol h v a new Source # 

Methods

addHeader :: a -> new -> new Source #

(KnownSymbol h, ToByteString v) => AddHeader Symbol h v (Headers ((:) * fst rest) a) (Headers ((:) * (Header h v) ((:) * fst rest)) a) Source # 

Methods

addHeader :: Headers ((* ': fst) rest) a -> Headers ((* ': Header h v) ((* ': fst) rest)) a -> new Source #

class BuildHeadersTo hs where Source #

Minimal complete definition

buildHeadersTo

Methods

buildHeadersTo :: [Header] -> HList hs Source #

Note: if there are multiple occurences of a header in the argument, the values are interspersed with commas before deserialization (see RFC2616 Sec 4.2)

Instances

class GetHeaders ls where Source #

Minimal complete definition

getHeaders

Methods

getHeaders :: ls -> [Header] Source #

Instances

(KnownSymbol h, ToByteString x, GetHeaders (HList xs)) => GetHeaders (HList ((:) * (Header h x) xs)) Source # 

Methods

getHeaders :: HList ((* ': Header h x) xs) -> [Header] Source #

GetHeaders (HList ([] *)) Source # 

Methods

getHeaders :: HList [*] -> [Header] Source #

(KnownSymbol h, GetHeaders (HList rest), ToByteString v) => GetHeaders (Headers ((:) * (Header h v) rest) a) Source # 

Methods

getHeaders :: Headers ((* ': Header h v) rest) a -> [Header] Source #

GetHeaders (Headers ([] *) a) Source # 

Methods

getHeaders :: Headers [*] a -> [Header] Source #

type family HeaderValMap (f :: * -> *) (xs :: [*]) where ... Source #

Equations

HeaderValMap f '[] = '[] 
HeaderValMap f (Header h x ': xs) = Header h (f x) ': HeaderValMap f xs 

data HList a where Source #

Constructors

HNil :: HList '[] 
HCons :: Header h x -> HList xs -> HList (Header h x ': xs) 

Instances

(KnownSymbol h, ToByteString x, GetHeaders (HList xs)) => GetHeaders (HList ((:) * (Header h x) xs)) Source # 

Methods

getHeaders :: HList ((* ': Header h x) xs) -> [Header] Source #

GetHeaders (HList ([] *)) Source # 

Methods

getHeaders :: HList [*] -> [Header] Source #