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

Safe Haskell | Safe
Language | Haskell2010

Servant.API.Header

Synopsis

- data Header sym a
  - = Header a
  - | MissingHeader
  - | UndecodableHeader ByteString

# 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

Constructors

Header a |
MissingHeader |
UndecodableHeader ByteString |

Instances

(KnownSymbol h, ToHttpApiData v) => AddHeader h v (Headers ((:) * fst rest) a) (Headers ((:) * (Header h v) ((:) * fst rest)) a) Source # |
Methods addOptionalHeader :: Header h v -> Headers ((* ': fst) rest) a -> Headers ((* ': Header h v) ((* ': fst) rest)) a
Functor (Header sym) Source # |
Methods fmap :: (a -> b) -> Header sym a -> Header sym b # (<$) :: a -> Header sym b -> Header sym a #
(KnownSymbol h, ToHttpApiData x, GetHeaders (HList xs)) => GetHeaders (HList ((:) * (Header h x) xs)) Source # |
Methods getHeaders :: HList ((* ': Header h x) xs) -> [Header] Source #
HasLink k sub => HasLink * ((:>) k * (Header sym a) sub) Source # |
Associated Types type MkLink ((:>) k * (Header sym a) sub) (endpoint :: (:>) k * (Header sym a) sub) :: * Source # Methods toLink :: Proxy ((k :> *) (Header sym a) sub) endpoint -> Link -> MkLink ((k :> *) (Header sym a) sub) endpoint Source #
Eq a => Eq (Header sym a) Source # |
Methods (==) :: Header sym a -> Header sym a -> Bool # (/=) :: Header sym a -> Header sym a -> Bool #
Show a => Show (Header sym a) Source # |
Methods showsPrec :: Int -> Header sym a -> ShowS # show :: Header sym a -> String # showList :: [Header sym a] -> ShowS #
(KnownSymbol h, GetHeaders (HList rest), ToHttpApiData v) => GetHeaders (Headers ((:) * (Header h v) rest) a) Source # |
Methods getHeaders :: Headers ((* ': Header h v) rest) a -> [Header] Source #
(FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h) => BuildHeadersTo ((:) * (Header h v) xs) Source # |
Methods buildHeadersTo :: [Header] -> HList ((* ': Header h v) xs) Source #
type MkLink * ((:>) k * (Header sym a) sub) Source # |
type MkLink * ((:>) k * (Header sym a) sub) = MkLink k sub