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

Safe HaskellNone
LanguageHaskell2010

Servant.API.Header

Synopsis

Documentation

data Header sym a Source

Extract the given header's value as a value of type a.

Example:

>>> newtype Referer = Referer Text deriving (Eq, Show)
>>> 
>>> -- GET /view-my-referer
>>> type MyApi = "view-my-referer" :> Header "from" Referer :> Get '[JSON] Referer

Instances

(KnownSymbol h, ToByteString v, (~) Bool (Contains h ((:) * fst rest)) False) => AddHeader Symbol h v (Headers ((:) * fst rest) a) (Headers ((:) * (Header h v) ((:) * fst rest)) a) 
HasLink k sub => HasLink * ((:>) * k (Header sym a) sub) 
Functor (Header sym) 
(KnownSymbol h, ToByteString x, GetHeaders (HList xs)) => GetHeaders (HList ((:) * (Header h x) xs)) 
Eq a => Eq (Header sym a) 
Show a => Show (Header sym a) 
(KnownSymbol h, GetHeaders (HList rest), ToByteString v) => GetHeaders (Headers ((:) * (Header h v) rest) a) 
Typeable (Symbol -> * -> *) Header 
(FromByteString v, BuildHeadersTo xs, KnownSymbol h, (~) Bool (Contains h xs) False) => BuildHeadersTo ((:) * (Header h v) xs) 
type MkLink * ((:>) * k (Header sym a) sub) = MkLink k sub 
>>> import Servant.API
>>> import Servant.Common.Text
>>> import Data.Aeson
>>> import Data.Text
>>> data Book
>>> instance ToJSON Book where { toJSON = undefined }