servant-client-core-0.20.3.0: Core functionality and class for client function generation for servant APIs

Safe Haskell | None
Language | Haskell2010

Servant.Client.Core.Request

Contents

- Modifiers

Synopsis

- type Request = RequestF RequestBody Builder
- data RequestF body path = Request {
  - requestPath :: path
  - requestQueryString :: Seq QueryItem
  - requestBody :: Maybe (body, MediaType)
  - requestAccept :: Seq MediaType
  - requestHeaders :: Seq Header
  - requestHttpVersion :: HttpVersion
  - requestMethod :: Method
  }
- data RequestBody
  - = RequestBodyLBS ByteString
  - | RequestBodyBS ByteString
  - | RequestBodySource (SourceIO ByteString)
- defaultRequest :: Request
- addHeader :: ToHttpApiData a => HeaderName -> a -> Request -> Request
- appendToPath :: Builder -> Request -> Request
- appendToQueryString :: Text -> Maybe ByteString -> Request -> Request
- encodeQueryParamValue :: ToHttpApiData a => a -> ByteString
- setQueryString :: Query -> Request -> Request
- setRequestBody :: RequestBody -> MediaType -> Request -> Request
- setRequestBodyLBS :: ByteString -> MediaType -> Request -> Request

# Documentation

type Request = RequestF RequestBody Builder Source #

data RequestF body path Source #

Constructors

Request |

Fields

- requestPath :: path
- requestQueryString :: Seq QueryItem
- requestBody :: Maybe (body, MediaType)
- requestAccept :: Seq MediaType
- requestHeaders :: Seq Header
- requestHttpVersion :: HttpVersion
- requestMethod :: Method

#### Instances

Instances details

Bifoldable RequestF Source # |
Instance details Defined in Servant.Client.Core.Request Methods bifold :: Monoid m => RequestF m m -> m Source # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> RequestF a b -> m Source # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> RequestF a b -> c Source # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> RequestF a b -> c Source #
Bifunctor RequestF Source # |
Instance details Defined in Servant.Client.Core.Request Methods bimap :: (a -> b) -> (c -> d) -> RequestF a c -> RequestF b d Source # first :: (a -> b) -> RequestF a c -> RequestF b c Source # second :: (b -> c) -> RequestF a b -> RequestF a c Source #
Bitraversable RequestF Source # |
Instance details Defined in Servant.Client.Core.Request Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> RequestF a b -> f (RequestF c d) Source #
Functor (RequestF body) Source # |
Instance details Defined in Servant.Client.Core.Request Methods fmap :: (a -> b) -> RequestF body a -> RequestF body b Source # (<$) :: a -> RequestF body b -> RequestF body a Source #
Foldable (RequestF body) Source # |

Instance details

Defined in Servant.Client.Core.Request

Methods

fold :: Monoid m => RequestF body m -> m Source #

foldMap :: Monoid m => (a -> m) -> RequestF body a -> m Source #

foldMap' :: Monoid m => (a -> m) -> RequestF body a -> m Source #

foldr :: (a -> b -> b) -> b -> RequestF body a -> b Source #

foldr' :: (a -> b -> b) -> b -> RequestF body a -> b Source #

foldl :: (b -> a -> b) -> b -> RequestF body a -> b Source #

foldl' :: (b -> a -> b) -> b -> RequestF body a -> b Source #

foldr1 :: (a -> a -> a) -> RequestF body a -> a Source #

foldl1 :: (a -> a -> a) -> RequestF body a -> a Source #

toList :: RequestF body a -> [a] Source #

null :: RequestF body a -> Bool Source #

length :: RequestF body a -> Int Source #

elem :: Eq a => a -> RequestF body a -> Bool Source #

maximum :: Ord a => RequestF body a -> a Source #

minimum :: Ord a => RequestF body a -> a Source #

sum :: Num a => RequestF body a -> a Source #

product :: Num a => RequestF body a -> a Source #

Traversable (RequestF body) Source # |
Instance details Defined in Servant.Client.Core.Request Methods traverse :: Applicative f => (a -> f b) -> RequestF body a -> f (RequestF body b) Source # sequenceA :: Applicative f => RequestF body (f a) -> f (RequestF body a) Source # mapM :: Monad m => (a -> m b) -> RequestF body a -> m (RequestF body b) Source # sequence :: Monad m => RequestF body (m a) -> m (RequestF body a) Source #
(NFData path, NFData body) => NFData (RequestF body path) Source # |
Instance details Defined in Servant.Client.Core.Request Methods rnf :: RequestF body path -> () Source #
Generic (RequestF body path) Source # |

Instance details

Defined in Servant.Client.Core.Request

Associated Types

type Rep (RequestF body path) |

Instance details

Defined in Servant.Client.Core.Request

type Rep (RequestF body path) = D1 ('MetaData "RequestF" "Servant.Client.Core.Request" "servant-client-core-0.20.3.0-8S9QaOrR0pTLkHAcl21Dlv" 'False) (C1 ('MetaCons "Request" 'PrefixI 'True) ((S1 ('MetaSel ('Just "requestPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 path) :*: (S1 ('MetaSel ('Just "requestQueryString") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq QueryItem)) :*: S1 ('MetaSel ('Just "requestBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (body, MediaType))))) :*: ((S1 ('MetaSel ('Just "requestAccept") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq MediaType)) :*: S1 ('MetaSel ('Just "requestHeaders") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq Header))) :*: (S1 ('MetaSel ('Just "requestHttpVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HttpVersion) :*: S1 ('MetaSel ('Just "requestMethod") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Method)))))

Methods

from :: RequestF body path -> Rep (RequestF body path) x Source #

to :: Rep (RequestF body path) x -> RequestF body path Source #

(Show a, Show b) => Show (RequestF a b) Source # |
Instance details Defined in Servant.Client.Core.Request Methods showsPrec :: Int -> RequestF a b -> ShowS Source # show :: RequestF a b -> String Source # showList :: [RequestF a b] -> ShowS Source #
(Eq path, Eq body) => Eq (RequestF body path) Source # |
Instance details Defined in Servant.Client.Core.Request Methods (==) :: RequestF body path -> RequestF body path -> Bool Source # (/=) :: RequestF body path -> RequestF body path -> Bool Source #
type Rep (RequestF body path) Source # |

Instance details

Defined in Servant.Client.Core.Request

type Rep (RequestF body path) = D1 ('MetaData "RequestF" "Servant.Client.Core.Request" "servant-client-core-0.20.3.0-8S9QaOrR0pTLkHAcl21Dlv" 'False) (C1 ('MetaCons "Request" 'PrefixI 'True) ((S1 ('MetaSel ('Just "requestPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 path) :*: (S1 ('MetaSel ('Just "requestQueryString") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq QueryItem)) :*: S1 ('MetaSel ('Just "requestBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe (body, MediaType))))) :*: ((S1 ('MetaSel ('Just "requestAccept") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq MediaType)) :*: S1 ('MetaSel ('Just "requestHeaders") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq Header))) :*: (S1 ('MetaSel ('Just "requestHttpVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HttpVersion) :*: S1 ('MetaSel ('Just "requestMethod") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Method)))))

data RequestBody Source #

The request body. R replica of the `http-client` `RequestBody`.

Constructors

RequestBodyLBS ByteString |
RequestBodyBS ByteString |
RequestBodySource (SourceIO ByteString) |

#### Instances

Instances details

Generic RequestBody Source # |

Instance details

Defined in Servant.Client.Core.Request

Associated Types

type Rep RequestBody |

Instance details

Defined in Servant.Client.Core.Request

type Rep RequestBody = D1 ('MetaData "RequestBody" "Servant.Client.Core.Request" "servant-client-core-0.20.3.0-8S9QaOrR0pTLkHAcl21Dlv" 'False) (C1 ('MetaCons "RequestBodyLBS" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ByteString)) :+: (C1 ('MetaCons "RequestBodyBS" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ByteString)) :+: C1 ('MetaCons "RequestBodySource" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (SourceIO ByteString)))))

Methods

from :: RequestBody -> Rep RequestBody x Source #

to :: Rep RequestBody x -> RequestBody Source #

Show RequestBody Source # |
Instance details Defined in Servant.Client.Core.Request Methods showsPrec :: Int -> RequestBody -> ShowS Source # show :: RequestBody -> String Source # showList :: [RequestBody] -> ShowS Source #
type Rep RequestBody Source # |

Instance details

Defined in Servant.Client.Core.Request

type Rep RequestBody = D1 ('MetaData "RequestBody" "Servant.Client.Core.Request" "servant-client-core-0.20.3.0-8S9QaOrR0pTLkHAcl21Dlv" 'False) (C1 ('MetaCons "RequestBodyLBS" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ByteString)) :+: (C1 ('MetaCons "RequestBodyBS" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ByteString)) :+: C1 ('MetaCons "RequestBodySource" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (SourceIO ByteString)))))

defaultRequest :: Request Source #

## Modifiers

addHeader :: ToHttpApiData a => HeaderName -> a -> Request -> Request Source #

Add header to the request being constructed.

appendToPath :: Builder -> Request -> Request Source #

Append extra path to the request being constructed.

Warning: This function assumes that the path fragment is already URL-encoded.

appendToQueryString Source #

Arguments

:: Text | query param name
-> Maybe ByteString | query param value
-> Request |
-> Request |

Append a query parameter to the request being constructed.

encodeQueryParamValue :: ToHttpApiData a => a -> ByteString Source #

Encode a query parameter value.

setQueryString :: Query -> Request -> Request Source #

setRequestBody :: RequestBody -> MediaType -> Request -> Request Source #

Set body and media type of the request being constructed.

Since: 0.12

setRequestBodyLBS :: ByteString -> MediaType -> Request -> Request Source #

Set body and media type of the request being constructed.

The body is set to the given bytestring using the `RequestBodyLBS` constructor.

Since: 0.12