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

Safe Haskell | None
Language | Haskell2010

Servant.Client.Core

Contents

- Client generation
- Request
- Authentication
- Generic Client
- Response
- BaseUrl
  - Streaming
- Writing HasClient instances

Description

This module provides backend-agnostic functionality for generating clients from `servant` APIs. By "backend," we mean something that concretely executes the request, such as:

- The `http-client` library
- The `haxl` library
- GHCJS via FFI

etc.

Each backend is encapsulated in a monad that is an instance of the `RunClient` class.

This library is primarily of interest to backend-writers and combinator-writers. For more information, see the README.md

Synopsis

- clientIn :: forall (m :: Type -> Type) api. HasClient m api => Proxy api -> Proxy m -> Client m api
- class RunClient m => HasClient (m :: Type -> Type) api where
  - type Client (m :: Type -> Type) api
  - clientWithRoute :: Proxy m -> Proxy api -> Request -> Client m api
  - hoistClientMonad :: Proxy m -> Proxy api -> (forall x. mon x -> mon' x) -> Client mon api -> Client mon' api
- foldMapUnion :: forall c a (as :: [Type]). All c as => Proxy c -> (forall x. c x => x -> a) -> Union as -> a
- matchUnion :: forall a (as :: [Type]). IsMember a as => Union as -> Maybe a
- 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
  }
- defaultRequest :: Request
- data RequestBody
  - = RequestBodyLBS ByteString
  - | RequestBodyBS ByteString
  - | RequestBodySource (SourceIO ByteString)
- mkAuthenticatedRequest :: AuthClientData a -> (AuthClientData a -> Request -> Request) -> AuthenticatedRequest a
- basicAuthReq :: BasicAuthData -> Request -> Request
- newtype AuthenticatedRequest a = AuthenticatedRequest {
  - unAuthReq :: (AuthClientData a, AuthClientData a -> Request -> Request)
  }
- type family AuthClientData a
- data ClientError
  - = FailureResponse (RequestF () (BaseUrl, ByteString)) Response
  - | DecodeFailure Text Response
  - | UnsupportedContentType MediaType Response
  - | InvalidContentTypeHeader Response
  - | ConnectionError SomeException
- data EmptyClient = EmptyClient
- type Response = ResponseF ByteString
- data ResponseF a = Response {
  - responseStatusCode :: Status
  - responseHeaders :: Seq Header
  - responseHttpVersion :: HttpVersion
  - responseBody :: a
  }
- class Monad m => RunClient (m :: Type -> Type) where
  - runRequestAcceptStatus :: Maybe [Status] -> Request -> m Response
  - throwClientError :: ClientError -> m a
- data BaseUrl = BaseUrl {
  - baseUrlScheme :: Scheme
  - baseUrlHost :: String
  - baseUrlPort :: Int
  - baseUrlPath :: String
  }
- data Scheme
  - = Http
  - | Https
- showBaseUrl :: BaseUrl -> String
- parseBaseUrl :: MonadThrow m => String -> m BaseUrl
- newtype InvalidBaseUrlException = InvalidBaseUrlException String
- class RunClient m => RunStreamingClient (m :: Type -> Type) where
  - withStreamingRequest :: Request -> (StreamingResponse -> IO a) -> m a
- type StreamingResponse = ResponseF (SourceIO ByteString)
- addHeader :: ToHttpApiData a => HeaderName -> a -> Request -> Request
- appendToQueryString :: Text -> Maybe ByteString -> Request -> Request
- appendToPath :: Builder -> Request -> Request
- setRequestBodyLBS :: ByteString -> MediaType -> Request -> Request
- setRequestBody :: RequestBody -> MediaType -> Request -> Request
- encodeQueryParamValue :: ToHttpApiData a => a -> ByteString

# Client generation

clientIn :: forall (m :: Type -> Type) api. HasClient m api => Proxy api -> Proxy m -> Client m api #

`clientIn` allows you to produce operations to query an API from a client within a `RunClient` monad.

    type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
            :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book -- POST /books

    myApi :: Proxy MyApi
    myApi = Proxy

    clientM :: Proxy ClientM
    clientM = Proxy

    getAllBooks :: ClientM [Book]
    postNewBook :: Book -> ClientM Book
    (getAllBooks :<|> postNewBook) = myApi `clientIn` clientM

class RunClient m => HasClient (m :: Type -> Type) api where #

This class lets us define how each API combinator influences the creation of an HTTP request.

Unless you are writing a new backend for `servant-client-core` or new combinators that you want to support client-generation, you can ignore this class.

Associated Types

type Client (m :: Type -> Type) api #

Methods

clientWithRoute :: Proxy m -> Proxy api -> Request -> Client m api #

hoistClientMonad :: Proxy m -> Proxy api -> (forall x. mon x -> mon' x) -> Client mon api -> Client mon' api #

#### Instances

Instances details

RunClient m => HasClient m EmptyAPI # | The client for `EmptyAPI` is simply `EmptyClient`.
    type MyAPI = "books" :> Get '[JSON] [Book] -- GET /books
            :<|> "nothing" :> EmptyAPI

    myApi :: Proxy MyApi
    myApi = Proxy

    getAllBooks :: ClientM [Book]
    (getAllBooks :<|> EmptyClient) = client myApi
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m EmptyAPI |
Instance details Defined in Servant.Client.Core.HasClient type Client m EmptyAPI = EmptyClient
Methods clientWithRoute :: Proxy m -> Proxy EmptyAPI -> Request -> Client m EmptyAPI # hoistClientMonad :: Proxy m -> Proxy EmptyAPI -> (forall x. mon x -> mon' x) -> Client mon EmptyAPI -> Client mon' EmptyAPI #
RunClient m => HasClient m Raw # | Pick a `Method` and specify where the server you want to query is. You get back the full `Response`.
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m Raw |
Instance details Defined in Servant.Client.Core.HasClient type Client m Raw = Method -> m Response
Methods clientWithRoute :: Proxy m -> Proxy Raw -> Request -> Client m Raw # hoistClientMonad :: Proxy m -> Proxy Raw -> (forall x. mon x -> mon' x) -> Client mon Raw -> Client mon' Raw #
RunClient m => HasClient m RawM # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m RawM |
Instance details Defined in Servant.Client.Core.HasClient type Client m RawM = Method -> m Response
Methods clientWithRoute :: Proxy m -> Proxy RawM -> Request -> Client m RawM # hoistClientMonad :: Proxy m -> Proxy RawM -> (forall x. mon x -> mon' x) -> Client mon RawM -> Client mon' RawM #
(RunClient m, TypeError (NoInstanceFor (HasClient m api)) :: Constraint) => HasClient m api # |
Instance details Defined in Servant.Client.Core.HasClient Methods clientWithRoute :: Proxy m -> Proxy api -> Request -> Client m api # hoistClientMonad :: Proxy m -> Proxy api -> (forall x. mon x -> mon' x) -> Client mon api -> Client mon' api #
(forall (n :: Type -> Type). GClient api n, HasClient m (ToServantApi api), RunClient m, ErrorIfNoGeneric api) => HasClient m (NamedRoutes api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (NamedRoutes api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (NamedRoutes api) = api (AsClientT m)
Methods clientWithRoute :: Proxy m -> Proxy (NamedRoutes api) -> Request -> Client m (NamedRoutes api) # hoistClientMonad :: Proxy m -> Proxy (NamedRoutes api) -> (forall x. mon x -> mon' x) -> Client mon (NamedRoutes api) -> Client mon' (NamedRoutes api) #
(HasClient m a, HasClient m b) => HasClient m (a :<|> b) # | A client querying function for `a `:<|>` b` will actually hand you one function for querying `a` and another one for querying `b`, stitching them together with `:<|>`, which really is just like a pair.
    type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
            :<|> "books" :> ReqBody '[JSON] Book :> Post Book -- POST /books

    myApi :: Proxy MyApi
    myApi = Proxy

    getAllBooks :: ClientM [Book]
    postNewBook :: Book -> ClientM Book
    (getAllBooks :<|> postNewBook) = client myApi
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (a :<|> b) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (a :<|> b) = Client m a :<|> Client m b
Methods clientWithRoute :: Proxy m -> Proxy (a :<|> b) -> Request -> Client m (a :<|> b) # hoistClientMonad :: Proxy m -> Proxy (a :<|> b) -> (forall x. mon x -> mon' x) -> Client mon (a :<|> b) -> Client mon' (a :<|> b) #
(RunClient m, ReflectMethod method) => HasClient m (NoContentVerb method) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (NoContentVerb method) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (NoContentVerb method) = m NoContent
Methods clientWithRoute :: Proxy m -> Proxy (NoContentVerb method) -> Request -> Client m (NoContentVerb method) # hoistClientMonad :: Proxy m -> Proxy (NoContentVerb method) -> (forall x. mon x -> mon' x) -> Client mon (NoContentVerb method) -> Client mon' (NoContentVerb method) #
(RunClient m, TypeError (PartialApplication HasClient arr) :: Constraint) => HasClient m (arr :> sub) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (arr :> sub) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (arr :> sub) = TypeError (PartialApplication HasClient arr) :: Type
Methods clientWithRoute :: Proxy m -> Proxy (arr :> sub) -> Request -> Client m (arr :> sub) # hoistClientMonad :: Proxy m -> Proxy (arr :> sub) -> (forall x. mon x -> mon' x) -> Client mon (arr :> sub) -> Client mon' (arr :> sub) #
(KnownSymbol path, HasClient m api) => HasClient m (path :> api) # | Make the querying function append `path` to the request path.
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (path :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (path :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (path :> api) -> Request -> Client m (path :> api) # hoistClientMonad :: Proxy m -> Proxy (path :> api) -> (forall x. mon x -> mon' x) -> Client mon (path :> api) -> Client mon' (path :> api) #
HasClient m api => HasClient m (HttpVersion :> api) # | Using a `HttpVersion` combinator in your API doesn't affect the client functions.
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (HttpVersion :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (HttpVersion :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (HttpVersion :> api) -> Request -> Client m (HttpVersion :> api) # hoistClientMonad :: Proxy m -> Proxy (HttpVersion :> api) -> (forall x. mon x -> mon' x) -> Client mon (HttpVersion :> api) -> Client mon' (HttpVersion :> api) #
HasClient m api => HasClient m (BasicAuth realm usr :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (BasicAuth realm usr :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (BasicAuth realm usr :> api) = BasicAuthData -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (BasicAuth realm usr :> api) -> Request -> Client m (BasicAuth realm usr :> api) # hoistClientMonad :: Proxy m -> Proxy (BasicAuth realm usr :> api) -> (forall x. mon x -> mon' x) -> Client mon (BasicAuth realm usr :> api) -> Client mon' (BasicAuth realm usr :> api) #
(ToHttpApiData a, HasClient m api) => HasClient m (Capture' mods capture a :> api) # | If you use a `Capture` in one of your endpoints in your API, the corresponding querying function will automatically take an additional argument of the type specified by your `Capture`. That function will take care of inserting a textual representation of this value at the right place in the request path. You can control how values for this type are turned into text by specifying a `ToHttpApiData` instance for your type. Example:
    type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book

    myApi :: Proxy MyApi
    myApi = Proxy

    getBook :: Text -> ClientM Book
    getBook = client myApi
    -- then you can just use "getBook" to query that endpoint
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Capture' mods capture a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Capture' mods capture a :> api) = a -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (Capture' mods capture a :> api) -> Request -> Client m (Capture' mods capture a :> api) # hoistClientMonad :: Proxy m -> Proxy (Capture' mods capture a :> api) -> (forall x. mon x -> mon' x) -> Client mon (Capture' mods capture a :> api) -> Client mon' (Capture' mods capture a :> api) #
(ToHttpApiData a, HasClient m sublayout) => HasClient m (CaptureAll capture a :> sublayout) # | If you use a `CaptureAll` in one of your endpoints in your API, the corresponding querying function will automatically take an additional argument of a list of the type specified by your `CaptureAll`. That function will take care of inserting a textual representation of this value at the right place in the request path. You can control how these values are turned into text by specifying a `ToHttpApiData` instance of your type. Example:
    type MyAPI = "src" :> CaptureAll Text -> Get '[JSON] SourceFile

    myApi :: Proxy
    myApi = Proxy
    getSourceFile :: [Text] -> ClientM SourceFile
    getSourceFile = client myApi
    -- then you can use "getSourceFile" to query that endpoint
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (CaptureAll capture a :> sublayout) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (CaptureAll capture a :> sublayout) = [a] -> Client m sublayout
Methods clientWithRoute :: Proxy m -> Proxy (CaptureAll capture a :> sublayout) -> Request -> Client m (CaptureAll capture a :> sublayout) # hoistClientMonad :: Proxy m -> Proxy (CaptureAll capture a :> sublayout) -> (forall x. mon x -> mon' x) -> Client mon (CaptureAll capture a :> sublayout) -> Client mon' (CaptureAll capture a :> sublayout) #
HasClient m api => HasClient m (Description desc :> api) # | Ignore ``Description`` in client functions.
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Description desc :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Description desc :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (Description desc :> api) -> Request -> Client m (Description desc :> api) # hoistClientMonad :: Proxy m -> Proxy (Description desc :> api) -> (forall x. mon x -> mon' x) -> Client mon (Description desc :> api) -> Client mon' (Description desc :> api) #
HasClient m api => HasClient m (Summary desc :> api) # | Ignore ``Summary`` in client functions.
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Summary desc :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Summary desc :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (Summary desc :> api) -> Request -> Client m (Summary desc :> api) # hoistClientMonad :: Proxy m -> Proxy (Summary desc :> api) -> (forall x. mon x -> mon' x) -> Client mon (Summary desc :> api) -> Client mon' (Summary desc :> api) #
HasClient m api => HasClient m (AuthProtect tag :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (AuthProtect tag :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (AuthProtect tag :> api) = AuthenticatedRequest (AuthProtect tag) -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (AuthProtect tag :> api) -> Request -> Client m (AuthProtect tag :> api) # hoistClientMonad :: Proxy m -> Proxy (AuthProtect tag :> api) -> (forall x. mon x -> mon' x) -> Client mon (AuthProtect tag :> api) -> Client mon' (AuthProtect tag :> api) #
(AtMostOneFragment api, FragmentUnique (Fragment a :> api), HasClient m api) => HasClient m (Fragment a :> api) # | Ignore ``Fragment`` in client functions. See https://ietf.org/rfc/rfc2616.html#section-15.1.3 for more details. Example:
    type MyApi = "books" :> Fragment Text :> Get '[JSON] [Book]

    myApi :: Proxy MyApi
    myApi = Proxy

    getBooks :: ClientM [Book]
    getBooks = client myApi
    -- then you can just use "getBooksBy" to query that endpoint.
    -- 'getBooks' for all books.
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Fragment a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Fragment a :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (Fragment a :> api) -> Request -> Client m (Fragment a :> api) # hoistClientMonad :: Proxy m -> Proxy (Fragment a :> api) -> (forall x. mon x -> mon' x) -> Client mon (Fragment a :> api) -> Client mon' (Fragment a :> api) #
(KnownSymbol sym, ToHttpApiData a, HasClient m api, SBoolI (FoldRequired mods)) => HasClient m (Header' mods sym a :> api) # | If you use a `Header` in one of your endpoints in your API, the corresponding querying function will automatically take an additional argument of the type specified by your `Header`, wrapped in Maybe. That function will take care of encoding this argument as Text in the request headers. All you need is for your type to have a `ToHttpApiData` instance. Example:
    newtype Referer = Referer { referrer :: Text }
      deriving (Eq, Show, Generic, ToHttpApiData)

               -- GET /view-my-referer
    type MyApi = "view-my-referer" :> Header "Referer" Referer :> Get '[JSON] Referer

    myApi :: Proxy MyApi
    myApi = Proxy

    viewReferer :: Maybe Referer -> ClientM Book
    viewReferer = client myApi
    -- then you can just use "viewRefer" to query that endpoint
    -- specifying Nothing or e.g Just "http://haskell.org/" as arguments
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Header' mods sym a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Header' mods sym a :> api) = RequiredArgument mods a -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (Header' mods sym a :> api) -> Request -> Client m (Header' mods sym a :> api) # hoistClientMonad :: Proxy m -> Proxy (Header' mods sym a :> api) -> (forall x. mon x -> mon' x) -> Client mon (Header' mods sym a :> api) -> Client mon' (Header' mods sym a :> api) #
HasClient m api => HasClient m (IsSecure :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (IsSecure :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (IsSecure :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (IsSecure :> api) -> Request -> Client m (IsSecure :> api) # hoistClientMonad :: Proxy m -> Proxy (IsSecure :> api) -> (forall x. mon x -> mon' x) -> Client mon (IsSecure :> api) -> Client mon' (IsSecure :> api) #
(KnownSymbol sym, HasClient m api) => HasClient m (QueryFlag sym :> api) # | If you use a `QueryFlag` in one of your endpoints in your API, the corresponding querying function will automatically take an additional `Bool` argument. If you give `False`, nothing will be added to the query string. Otherwise, this function will insert a value-less query string parameter under the name associated to your `QueryFlag`. Example:
    type MyApi = "books" :> QueryFlag "published" :> Get '[JSON] [Book]

    myApi :: Proxy MyApi
    myApi = Proxy

    getBooks :: Bool -> ClientM [Book]
    getBooks = client myApi
    -- then you can just use "getBooks" to query that endpoint.
    -- 'getBooksBy False' for all books
    -- 'getBooksBy True' to only get _already published_ books
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (QueryFlag sym :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (QueryFlag sym :> api) = Bool -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (QueryFlag sym :> api) -> Request -> Client m (QueryFlag sym :> api) # hoistClientMonad :: Proxy m -> Proxy (QueryFlag sym :> api) -> (forall x. mon x -> mon' x) -> Client mon (QueryFlag sym :> api) -> Client mon' (QueryFlag sym :> api) #
(KnownSymbol sym, ToHttpApiData a, HasClient m api, SBoolI (FoldRequired mods)) => HasClient m (QueryParam' mods sym a :> api) # | If you use a `QueryParam` in one of your endpoints in your API, the corresponding querying function will automatically take an additional argument of the type specified by your `QueryParam`, enclosed in Maybe. If you give Nothing, nothing will be added to the query string. If you give a non-`Nothing` value, this function will take care of inserting a textual representation of this value in the query string. You can control how values for your type are turned into text by specifying a `ToHttpApiData` instance for your type. Example:
    type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book]

    myApi :: Proxy MyApi
    myApi = Proxy

    getBooksBy :: Maybe Text -> ClientM [Book]
    getBooksBy = client myApi
    -- then you can just use "getBooksBy" to query that endpoint.
    -- 'getBooksBy Nothing' for all books
    -- 'getBooksBy (Just "Isaac Asimov")' to get all books by Isaac Asimov
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (QueryParam' mods sym a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (QueryParam' mods sym a :> api) = RequiredArgument mods a -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (QueryParam' mods sym a :> api) -> Request -> Client m (QueryParam' mods sym a :> api) # hoistClientMonad :: Proxy m -> Proxy (QueryParam' mods sym a :> api) -> (forall x. mon x -> mon' x) -> Client mon (QueryParam' mods sym a :> api) -> Client mon' (QueryParam' mods sym a :> api) #
(KnownSymbol sym, ToHttpApiData a, HasClient m api) => HasClient m (QueryParams sym a :> api) # | If you use a `QueryParams` in one of your endpoints in your API, the corresponding querying function will automatically take an additional argument, a list of values of the type specified by your `QueryParams`. If you give an empty list, nothing will be added to the query string. Otherwise, this function will take care of inserting a textual representation of your values in the query string, under the same query string parameter name. You can control how values for your type are turned into text by specifying a `ToHttpApiData` instance for your type. Example:
    type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book]

    myApi :: Proxy MyApi
    myApi = Proxy

    getBooksBy :: [Text] -> ClientM [Book]
    getBooksBy = client myApi
    -- then you can just use "getBooksBy" to query that endpoint.
    -- 'getBooksBy []' for all books
    -- 'getBooksBy ["Isaac Asimov", "Robert A. Heinlein"]'
    --   to get all books by Asimov and Heinlein
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (QueryParams sym a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (QueryParams sym a :> api) = [a] -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (QueryParams sym a :> api) -> Request -> Client m (QueryParams sym a :> api) # hoistClientMonad :: Proxy m -> Proxy (QueryParams sym a :> api) -> (forall x. mon x -> mon' x) -> Client mon (QueryParams sym a :> api) -> Client mon' (QueryParams sym a :> api) #
(KnownSymbol sym, ToDeepQuery a, HasClient m api) => HasClient m (DeepQuery sym a :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (DeepQuery sym a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (DeepQuery sym a :> api) = a -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (DeepQuery sym a :> api) -> Request -> Client m (DeepQuery sym a :> api) # hoistClientMonad :: Proxy m -> Proxy (DeepQuery sym a :> api) -> (forall x. mon x -> mon' x) -> Client mon (DeepQuery sym a :> api) -> Client mon' (DeepQuery sym a :> api) #
HasClient m api => HasClient m (QueryString :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (QueryString :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (QueryString :> api) = Query -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (QueryString :> api) -> Request -> Client m (QueryString :> api) # hoistClientMonad :: Proxy m -> Proxy (QueryString :> api) -> (forall x. mon x -> mon' x) -> Client mon (QueryString :> api) -> Client mon' (QueryString :> api) #
HasClient m api => HasClient m (RemoteHost :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (RemoteHost :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (RemoteHost :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (RemoteHost :> api) -> Request -> Client m (RemoteHost :> api) # hoistClientMonad :: Proxy m -> Proxy (RemoteHost :> api) -> (forall x. mon x -> mon' x) -> Client mon (RemoteHost :> api) -> Client mon' (RemoteHost :> api) #
(MimeRender ct a, HasClient m api) => HasClient m (ReqBody' mods (ct ': cts) a :> api) # | If you use a `ReqBody` in one of your endpoints in your API, the corresponding querying function will automatically take an additional argument of the type specified by your `ReqBody`. That function will take care of encoding this argument as JSON and of using it as the request body. All you need is for your type to have a `ToJSON` instance. Example:
    type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book

    myApi :: Proxy MyApi
    myApi = Proxy

    addBook :: Book -> ClientM Book
    addBook = client myApi
    -- then you can just use "addBook" to query that endpoint
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (ReqBody' mods (ct ': cts) a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (ReqBody' mods (ct ': cts) a :> api) = a -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (ReqBody' mods (ct ': cts) a :> api) -> Request -> Client m (ReqBody' mods (ct ': cts) a :> api) # hoistClientMonad :: Proxy m -> Proxy (ReqBody' mods (ct ': cts) a :> api) -> (forall x. mon x -> mon' x) -> Client mon (ReqBody' mods (ct ': cts) a :> api) -> Client mon' (ReqBody' mods (ct ': cts) a :> api) #
(HasClient m api, MimeRender ctype chunk, FramingRender framing, ToSourceIO chunk a) => HasClient m (StreamBody' mods framing ctype a :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (StreamBody' mods framing ctype a :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (StreamBody' mods framing ctype a :> api) = a -> Client m api
Methods clientWithRoute :: Proxy m -> Proxy (StreamBody' mods framing ctype a :> api) -> Request -> Client m (StreamBody' mods framing ctype a :> api) # hoistClientMonad :: Proxy m -> Proxy (StreamBody' mods framing ctype a :> api) -> (forall x. mon x -> mon' x) -> Client mon (StreamBody' mods framing ctype a :> api) -> Client mon' (StreamBody' mods framing ctype a :> api) #
HasClient m subapi => HasClient m (WithResource res :> subapi) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (WithResource res :> subapi) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (WithResource res :> subapi) = Client m subapi
Methods clientWithRoute :: Proxy m -> Proxy (WithResource res :> subapi) -> Request -> Client m (WithResource res :> subapi) # hoistClientMonad :: Proxy m -> Proxy (WithResource res :> subapi) -> (forall x. mon x -> mon' x) -> Client mon (WithResource res :> subapi) -> Client mon' (WithResource res :> subapi) #
HasClient m api => HasClient m (Vault :> api) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Vault :> api) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Vault :> api) = Client m api
Methods clientWithRoute :: Proxy m -> Proxy (Vault :> api) -> Request -> Client m (Vault :> api) # hoistClientMonad :: Proxy m -> Proxy (Vault :> api) -> (forall x. mon x -> mon' x) -> Client mon (Vault :> api) -> Client mon' (Vault :> api) #
(RunClient m, TypeError (NoInstanceForSub (HasClient m) ty) :: Constraint) => HasClient m (ty :> sub) # |
Instance details Defined in Servant.Client.Core.HasClient Methods clientWithRoute :: Proxy m -> Proxy (ty :> sub) -> Request -> Client m (ty :> sub) # hoistClientMonad :: Proxy m -> Proxy (ty :> sub) -> (forall x. mon x -> mon' x) -> Client mon (ty :> sub) -> Client mon' (ty :> sub) #
(RunClient m, contentTypes ~ (contentType ': otherContentTypes), as ~ (a ': as'), AllMime contentTypes, ReflectMethod method, All (UnrenderResponse contentTypes) as, All HasStatus as, HasStatuses as', Unique (Statuses as)) => HasClient m (UVerb method contentTypes as) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (UVerb method contentTypes as) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (UVerb method contentTypes as) = m (Union as)
Methods clientWithRoute :: Proxy m -> Proxy (UVerb method contentTypes as) -> Request -> Client m (UVerb method contentTypes as) # hoistClientMonad :: Proxy m -> Proxy (UVerb method contentTypes as) -> (forall x. mon x -> mon' x) -> Client mon (UVerb method contentTypes as) -> Client mon' (UVerb method contentTypes as) #
HasClient m subapi => HasClient m (WithNamedContext name context subapi) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (WithNamedContext name context subapi) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (WithNamedContext name context subapi) = Client m subapi
Methods clientWithRoute :: Proxy m -> Proxy (WithNamedContext name context subapi) -> Request -> Client m (WithNamedContext name context subapi) # hoistClientMonad :: Proxy m -> Proxy (WithNamedContext name context subapi) -> (forall x. mon x -> mon' x) -> Client mon (WithNamedContext name context subapi) -> Client mon' (WithNamedContext name context subapi) #
(RunClient m, ReflectMethod method, KnownNat status) => HasClient m (Verb method status cts NoContent) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Verb method status cts NoContent) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts NoContent) = m NoContent
type Client m (Verb method status cts' a) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts' a) = m a
Methods clientWithRoute :: Proxy m -> Proxy (Verb method status cts NoContent) -> Request -> Client m (Verb method status cts NoContent) # hoistClientMonad :: Proxy m -> Proxy (Verb method status cts NoContent) -> (forall x. mon x -> mon' x) -> Client mon (Verb method status cts NoContent) -> Client mon' (Verb method status cts NoContent) #
(RunClient m, BuildHeadersTo ls, ReflectMethod method, KnownNat status) => HasClient m (Verb method status cts (Headers ls NoContent)) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Verb method status cts (Headers ls NoContent)) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts (Headers ls NoContent)) = m (Headers ls NoContent)
type Client m (Verb method status cts' (Headers ls a)) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts' (Headers ls a)) = m (Headers ls a)
type Client m (Verb method status cts' a) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts' a) = m a
Methods clientWithRoute :: Proxy m -> Proxy (Verb method status cts (Headers ls NoContent)) -> Request -> Client m (Verb method status cts (Headers ls NoContent)) # hoistClientMonad :: Proxy m -> Proxy (Verb method status cts (Headers ls NoContent)) -> (forall x. mon x -> mon' x) -> Client mon (Verb method status cts (Headers ls NoContent)) -> Client mon' (Verb method status cts (Headers ls NoContent)) #
(RunClient m, MimeUnrender ct a, BuildHeadersTo ls, KnownNat status, ReflectMethod method, cts' ~ (ct ': cts)) => HasClient m (Verb method status cts' (Headers ls a)) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Verb method status cts' (Headers ls a)) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts' (Headers ls a)) = m (Headers ls a)
type Client m (Verb method status cts' a) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts' a) = m a
Methods clientWithRoute :: Proxy m -> Proxy (Verb method status cts' (Headers ls a)) -> Request -> Client m (Verb method status cts' (Headers ls a)) # hoistClientMonad :: Proxy m -> Proxy (Verb method status cts' (Headers ls a)) -> (forall x. mon x -> mon' x) -> Client mon (Verb method status cts' (Headers ls a)) -> Client mon' (Verb method status cts' (Headers ls a)) #
(RunClient m, MimeUnrender ct a, ReflectMethod method, cts' ~ (ct ': cts), KnownNat status) => HasClient m (Verb method status cts' a) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Verb method status cts' a) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Verb method status cts' a) = m a
Methods clientWithRoute :: Proxy m -> Proxy (Verb method status cts' a) -> Request -> Client m (Verb method status cts' a) # hoistClientMonad :: Proxy m -> Proxy (Verb method status cts' a) -> (forall x. mon x -> mon' x) -> Client mon (Verb method status cts' a) -> Client mon' (Verb method status cts' a) #
(RunStreamingClient m, MimeUnrender ct chunk, ReflectMethod method, FramingUnrender framing, FromSourceIO chunk a, BuildHeadersTo hs) => HasClient m (Stream method status framing ct (Headers hs a)) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Stream method status framing ct (Headers hs a)) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Stream method status framing ct (Headers hs a)) = m (Headers hs a)
type Client m (Stream method status framing ct a) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Stream method status framing ct a) = m a
Methods clientWithRoute :: Proxy m -> Proxy (Stream method status framing ct (Headers hs a)) -> Request -> Client m (Stream method status framing ct (Headers hs a)) # hoistClientMonad :: Proxy m -> Proxy (Stream method status framing ct (Headers hs a)) -> (forall x. mon x -> mon' x) -> Client mon (Stream method status framing ct (Headers hs a)) -> Client mon' (Stream method status framing ct (Headers hs a)) #
(RunStreamingClient m, MimeUnrender ct chunk, ReflectMethod method, FramingUnrender framing, FromSourceIO chunk a) => HasClient m (Stream method status framing ct a) # |
Instance details Defined in Servant.Client.Core.HasClient Associated Types
type Client m (Stream method status framing ct a) |
Instance details Defined in Servant.Client.Core.HasClient type Client m (Stream method status framing ct a) = m a
Methods clientWithRoute :: Proxy m -> Proxy (Stream method status framing ct a) -> Request -> Client m (Stream method status framing ct a) # hoistClientMonad :: Proxy m -> Proxy (Stream method status framing ct a) -> (forall x. mon x -> mon' x) -> Client mon (Stream method status framing ct a) -> Client mon' (Stream method status framing ct a) #

foldMapUnion :: forall c a (as :: [Type]). All c as => Proxy c -> (forall x. c x => x -> a) -> Union as -> a #

Convenience function to apply a function to an unknown union element using a type class. All elements of the union must have instances in the type class, and the function is applied unconditionally.

See also: `matchUnion`.

matchUnion :: forall a (as :: [Type]). IsMember a as => Union as -> Maybe a #

Convenience function to extract a union element using `cast`, ie. return the value if the selected type happens to be the actual type of the union in this value, or `Nothing` otherwise.

See also: `foldMapUnion`.

# Request

type Request = RequestF RequestBody Builder #

data RequestF body path #

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 # |
Instance details Defined in Servant.Client.Core.Request Methods bifold :: Monoid m => RequestF m m -> m # bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> RequestF a b -> m # bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> RequestF a b -> c # bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> RequestF a b -> c #
Bifunctor RequestF # |
Instance details Defined in Servant.Client.Core.Request Methods bimap :: (a -> b) -> (c -> d) -> RequestF a c -> RequestF b d # first :: (a -> b) -> RequestF a c -> RequestF b c # second :: (b -> c) -> RequestF a b -> RequestF a c #
Bitraversable RequestF # |
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) #
Functor (RequestF body) # |
Instance details Defined in Servant.Client.Core.Request Methods fmap :: (a -> b) -> RequestF body a -> RequestF body b # (<$) :: a -> RequestF body b -> RequestF body a #
Foldable (RequestF body) # |
Instance details Defined in Servant.Client.Core.Request Methods fold :: Monoid m => RequestF body m -> m # foldMap :: Monoid m => (a -> m) -> RequestF body a -> m # foldMap' :: Monoid m => (a -> m) -> RequestF body a -> m # foldr :: (a -> b -> b) -> b -> RequestF body a -> b # foldr' :: (a -> b -> b) -> b -> RequestF body a -> b # foldl :: (b -> a -> b) -> b -> RequestF body a -> b # foldl' :: (b -> a -> b) -> b -> RequestF body a -> b # foldr1 :: (a -> a -> a) -> RequestF body a -> a # foldl1 :: (a -> a -> a) -> RequestF body a -> a # toList :: RequestF body a -> [a] # null :: RequestF body a -> Bool # length :: RequestF body a -> Int # elem :: Eq a => a -> RequestF body a -> Bool # maximum :: Ord a => RequestF body a -> a # minimum :: Ord a => RequestF body a -> a # sum :: Num a => RequestF body a -> a # product :: Num a => RequestF body a -> a #
Traversable (RequestF body) # |
Instance details Defined in Servant.Client.Core.Request Methods traverse :: Applicative f => (a -> f b) -> RequestF body a -> f (RequestF body b) # sequenceA :: Applicative f => RequestF body (f a) -> f (RequestF body a) # mapM :: Monad m => (a -> m b) -> RequestF body a -> m (RequestF body b) # sequence :: Monad m => RequestF body (m a) -> m (RequestF body a) #
(NFData path, NFData body) => NFData (RequestF body path) # |
Instance details Defined in Servant.Client.Core.Request Methods rnf :: RequestF body path -> () #
Generic (RequestF body path) # |
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.2-JDs2vIfQ3Bk9wqlGzwnuNZ" '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 # to :: Rep (RequestF body path) x -> RequestF body path #
(Show a, Show b) => Show (RequestF a b) # |
Instance details Defined in Servant.Client.Core.Request Methods showsPrec :: Int -> RequestF a b -> ShowS # show :: RequestF a b -> String # showList :: [RequestF a b] -> ShowS #
(Eq path, Eq body) => Eq (RequestF body path) # |
Instance details Defined in Servant.Client.Core.Request Methods (==) :: RequestF body path -> RequestF body path -> Bool # (/=) :: RequestF body path -> RequestF body path -> Bool #
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.2-JDs2vIfQ3Bk9wqlGzwnuNZ" '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)))))

defaultRequest :: Request #

data RequestBody #

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

Constructors

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

#### Instances

Instances details

Generic RequestBody # |
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.2-JDs2vIfQ3Bk9wqlGzwnuNZ" '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 # to :: Rep RequestBody x -> RequestBody #
Show RequestBody # |
Instance details Defined in Servant.Client.Core.Request Methods showsPrec :: Int -> RequestBody -> ShowS # show :: RequestBody -> String # showList :: [RequestBody] -> ShowS #
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.2-JDs2vIfQ3Bk9wqlGzwnuNZ" '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)))))

# Authentication

mkAuthenticatedRequest :: AuthClientData a -> (AuthClientData a -> Request -> Request) -> AuthenticatedRequest a #

Handy helper to avoid wrapping datatypes in tuples everywhere.

NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE

basicAuthReq :: BasicAuthData -> Request -> Request #

Authenticate a request using Basic Authentication

newtype AuthenticatedRequest a #

For better type inference and to avoid usage of a data family, we newtype wrap the combination of some `AuthClientData` and a function to add authentication data to a request

NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE

Constructors

AuthenticatedRequest |
Fields unAuthReq :: (AuthClientData a, AuthClientData a -> Request -> Request)

type family AuthClientData a #

For a resource protected by authentication (e.g. AuthProtect), we need to provide the client with some data used to add authentication data to a request

NOTE: THIS API IS EXPERIMENTAL AND SUBJECT TO CHANGE

# Generic Client

data ClientError #

A type representing possible errors in a request

Note that this type substantially changed in 0.12.

Constructors

FailureResponse (RequestF () (BaseUrl, ByteString)) Response | The server returned an error response including the failing request. `requestPath` includes the `BaseUrl` and the path of the request.
DecodeFailure Text Response | The body could not be decoded at the expected type
UnsupportedContentType MediaType Response | The content-type of the response is not supported
InvalidContentTypeHeader Response | The content-type header is invalid
ConnectionError SomeException | There was a connection error, and no response was received

#### Instances

Instances details

NFData ClientError # | Note: an exception in `ConnectionError` might not be evaluated fully, We only `rnf` its `show`ed value.
Instance details Defined in Servant.Client.Core.ClientError Methods rnf :: ClientError -> () #
Exception ClientError # |
Instance details Defined in Servant.Client.Core.ClientError Methods toException :: ClientError -> SomeException # fromException :: SomeException -> Maybe ClientError # displayException :: ClientError -> String # backtraceDesired :: ClientError -> Bool #
Generic ClientError # |
Instance details Defined in Servant.Client.Core.ClientError Associated Types
type Rep ClientError |
Instance details Defined in Servant.Client.Core.ClientError type Rep ClientError = D1 ('MetaData "ClientError" "Servant.Client.Core.ClientError" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) ((C1 ('MetaCons "FailureResponse" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (RequestF () (BaseUrl, ByteString))) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response)) :+: C1 ('MetaCons "DecodeFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response))) :+: (C1 ('MetaCons "UnsupportedContentType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 MediaType) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response)) :+: (C1 ('MetaCons "InvalidContentTypeHeader" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response)) :+: C1 ('MetaCons "ConnectionError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SomeException)))))
Methods from :: ClientError -> Rep ClientError x # to :: Rep ClientError x -> ClientError #
Show ClientError # |
Instance details Defined in Servant.Client.Core.ClientError Methods showsPrec :: Int -> ClientError -> ShowS # show :: ClientError -> String # showList :: [ClientError] -> ShowS #
Eq ClientError # |
Instance details Defined in Servant.Client.Core.ClientError Methods (==) :: ClientError -> ClientError -> Bool # (/=) :: ClientError -> ClientError -> Bool #
type Rep ClientError # |
Instance details Defined in Servant.Client.Core.ClientError type Rep ClientError = D1 ('MetaData "ClientError" "Servant.Client.Core.ClientError" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) ((C1 ('MetaCons "FailureResponse" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (RequestF () (BaseUrl, ByteString))) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response)) :+: C1 ('MetaCons "DecodeFailure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response))) :+: (C1 ('MetaCons "UnsupportedContentType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 MediaType) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response)) :+: (C1 ('MetaCons "InvalidContentTypeHeader" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Response)) :+: C1 ('MetaCons "ConnectionError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 SomeException)))))

data EmptyClient #

Singleton type representing a client for an empty API.

Constructors

EmptyClient |

#### Instances

Instances details

Bounded EmptyClient # |
Instance details Defined in Servant.Client.Core.HasClient Methods minBound :: EmptyClient # maxBound :: EmptyClient #
Enum EmptyClient # |
Instance details Defined in Servant.Client.Core.HasClient Methods succ :: EmptyClient -> EmptyClient # pred :: EmptyClient -> EmptyClient # toEnum :: Int -> EmptyClient # fromEnum :: EmptyClient -> Int # enumFrom :: EmptyClient -> [EmptyClient] # enumFromThen :: EmptyClient -> EmptyClient -> [EmptyClient] # enumFromTo :: EmptyClient -> EmptyClient -> [EmptyClient] # enumFromThenTo :: EmptyClient -> EmptyClient -> EmptyClient -> [EmptyClient] #
Show EmptyClient # |
Instance details Defined in Servant.Client.Core.HasClient Methods showsPrec :: Int -> EmptyClient -> ShowS # show :: EmptyClient -> String # showList :: [EmptyClient] -> ShowS #
Eq EmptyClient # |
Instance details Defined in Servant.Client.Core.HasClient Methods (==) :: EmptyClient -> EmptyClient -> Bool # (/=) :: EmptyClient -> EmptyClient -> Bool #

# Response

type Response = ResponseF ByteString #

data ResponseF a #

Constructors

Response |
Fields responseStatusCode :: Status responseHeaders :: Seq Header responseHttpVersion :: HttpVersion responseBody :: a

#### Instances

Instances details

Functor ResponseF # |
Instance details Defined in Servant.Client.Core.Response Methods fmap :: (a -> b) -> ResponseF a -> ResponseF b # (<$) :: a -> ResponseF b -> ResponseF a #
Foldable ResponseF # |
Instance details Defined in Servant.Client.Core.Response Methods fold :: Monoid m => ResponseF m -> m # foldMap :: Monoid m => (a -> m) -> ResponseF a -> m # foldMap' :: Monoid m => (a -> m) -> ResponseF a -> m # foldr :: (a -> b -> b) -> b -> ResponseF a -> b # foldr' :: (a -> b -> b) -> b -> ResponseF a -> b # foldl :: (b -> a -> b) -> b -> ResponseF a -> b # foldl' :: (b -> a -> b) -> b -> ResponseF a -> b # foldr1 :: (a -> a -> a) -> ResponseF a -> a # foldl1 :: (a -> a -> a) -> ResponseF a -> a # toList :: ResponseF a -> [a] # null :: ResponseF a -> Bool # length :: ResponseF a -> Int # elem :: Eq a => a -> ResponseF a -> Bool # maximum :: Ord a => ResponseF a -> a # minimum :: Ord a => ResponseF a -> a # sum :: Num a => ResponseF a -> a # product :: Num a => ResponseF a -> a #
Traversable ResponseF # |
Instance details Defined in Servant.Client.Core.Response Methods traverse :: Applicative f => (a -> f b) -> ResponseF a -> f (ResponseF b) # sequenceA :: Applicative f => ResponseF (f a) -> f (ResponseF a) # mapM :: Monad m => (a -> m b) -> ResponseF a -> m (ResponseF b) # sequence :: Monad m => ResponseF (m a) -> m (ResponseF a) #
NFData a => NFData (ResponseF a) # |
Instance details Defined in Servant.Client.Core.Response Methods rnf :: ResponseF a -> () #
Generic (ResponseF a) # |
Instance details Defined in Servant.Client.Core.Response Associated Types
type Rep (ResponseF a) |
Instance details Defined in Servant.Client.Core.Response type Rep (ResponseF a) = D1 ('MetaData "ResponseF" "Servant.Client.Core.Response" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "Response" 'PrefixI 'True) ((S1 ('MetaSel ('Just "responseStatusCode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Status) :*: S1 ('MetaSel ('Just "responseHeaders") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq Header))) :*: (S1 ('MetaSel ('Just "responseHttpVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HttpVersion) :*: S1 ('MetaSel ('Just "responseBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))))
Methods from :: ResponseF a -> Rep (ResponseF a) x # to :: Rep (ResponseF a) x -> ResponseF a #
Show a => Show (ResponseF a) # |
Instance details Defined in Servant.Client.Core.Response Methods showsPrec :: Int -> ResponseF a -> ShowS # show :: ResponseF a -> String # showList :: [ResponseF a] -> ShowS #
Eq a => Eq (ResponseF a) # |
Instance details Defined in Servant.Client.Core.Response Methods (==) :: ResponseF a -> ResponseF a -> Bool # (/=) :: ResponseF a -> ResponseF a -> Bool #
type Rep (ResponseF a) # |
Instance details Defined in Servant.Client.Core.Response type Rep (ResponseF a) = D1 ('MetaData "ResponseF" "Servant.Client.Core.Response" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "Response" 'PrefixI 'True) ((S1 ('MetaSel ('Just "responseStatusCode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Status) :*: S1 ('MetaSel ('Just "responseHeaders") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq Header))) :*: (S1 ('MetaSel ('Just "responseHttpVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 HttpVersion) :*: S1 ('MetaSel ('Just "responseBody") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))))

class Monad m => RunClient (m :: Type -> Type) where #

Methods

runRequestAcceptStatus :: Maybe [Status] -> Request -> m Response #

How to make a request, with an optional list of status codes to not throw exceptions for (default: [200..299]).

throwClientError :: ClientError -> m a #

#### Instances

Instances details

ClientF ~ f => RunClient (Free f) # |
Instance details Defined in Servant.Client.Core.RunClient Methods runRequestAcceptStatus :: Maybe [Status] -> Request -> Free f Response # throwClientError :: ClientError -> Free f a #

# BaseUrl

data BaseUrl #

Simple data type to represent the target of HTTP requests for servant's automatically-generated clients.

Constructors

BaseUrl |
Fields baseUrlScheme :: Scheme URI scheme to use baseUrlHost :: String host (eg "haskell.org") baseUrlPort :: Int port (eg 80) baseUrlPath :: String path (eg "ab/c")

#### Instances

Instances details

FromJSON BaseUrl # |
    >>> parseBaseUrl "api.example.com" >>= decode . encode :: Maybe BaseUrl
    Just (BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = ""})
Instance details Defined in Servant.Client.Core.BaseUrl Methods parseJSON :: Value -> Parser BaseUrl # parseJSONList :: Value -> Parser [BaseUrl] # omittedField :: Maybe BaseUrl #
FromJSONKey BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods fromJSONKey :: FromJSONKeyFunction BaseUrl # fromJSONKeyList :: FromJSONKeyFunction [BaseUrl] #
ToJSON BaseUrl # |
    >>> traverse_ (LBS8.putStrLn . encode) (parseBaseUrl "api.example.com" :: [BaseUrl])
    "http://api.example.com"
Instance details Defined in Servant.Client.Core.BaseUrl Methods toJSON :: BaseUrl -> Value # toEncoding :: BaseUrl -> Encoding # toJSONList :: [BaseUrl] -> Value # toEncodingList :: [BaseUrl] -> Encoding # omitField :: BaseUrl -> Bool #
ToJSONKey BaseUrl # |
    >>> :{
    traverse_ (LBS8.putStrLn . encode) $ do
      u1 <- parseBaseUrl "api.example.com" :: [BaseUrl]
      u2 <- parseBaseUrl "example.com" :: [BaseUrl]
      return $ Map.fromList [(u1, 'x'), (u2, 'y')]
    :}
    {"http://api.example.com":"x","http://example.com":"y"}
Instance details Defined in Servant.Client.Core.BaseUrl Methods toJSONKey :: ToJSONKeyFunction BaseUrl # toJSONKeyList :: ToJSONKeyFunction [BaseUrl] #
NFData BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods rnf :: BaseUrl -> () #
Data BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BaseUrl -> c BaseUrl # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BaseUrl # toConstr :: BaseUrl -> Constr # dataTypeOf :: BaseUrl -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BaseUrl) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BaseUrl) # gmapT :: (forall b. Data b => b -> b) -> BaseUrl -> BaseUrl # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BaseUrl -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BaseUrl -> r # gmapQ :: (forall d. Data d => d -> u) -> BaseUrl -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BaseUrl -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BaseUrl -> m BaseUrl #
Generic BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Associated Types
type Rep BaseUrl |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep BaseUrl = D1 ('MetaData "BaseUrl" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "BaseUrl" 'PrefixI 'True) ((S1 ('MetaSel ('Just "baseUrlScheme") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Scheme) :*: S1 ('MetaSel ('Just "baseUrlHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String)) :*: (S1 ('MetaSel ('Just "baseUrlPort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "baseUrlPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String))))
Methods from :: BaseUrl -> Rep BaseUrl x # to :: Rep BaseUrl x -> BaseUrl #
Show BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> BaseUrl -> ShowS # show :: BaseUrl -> String # showList :: [BaseUrl] -> ShowS #
Eq BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods (==) :: BaseUrl -> BaseUrl -> Bool # (/=) :: BaseUrl -> BaseUrl -> Bool #
Ord BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods compare :: BaseUrl -> BaseUrl -> Ordering # (<) :: BaseUrl -> BaseUrl -> Bool # (<=) :: BaseUrl -> BaseUrl -> Bool # (>) :: BaseUrl -> BaseUrl -> Bool # (>=) :: BaseUrl -> BaseUrl -> Bool # max :: BaseUrl -> BaseUrl -> BaseUrl # min :: BaseUrl -> BaseUrl -> BaseUrl #
Lift BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods lift :: Quote m => BaseUrl -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => BaseUrl -> Code m BaseUrl #
type Rep BaseUrl # |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep BaseUrl = D1 ('MetaData "BaseUrl" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "BaseUrl" 'PrefixI 'True) ((S1 ('MetaSel ('Just "baseUrlScheme") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Scheme) :*: S1 ('MetaSel ('Just "baseUrlHost") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String)) :*: (S1 ('MetaSel ('Just "baseUrlPort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "baseUrlPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 String))))

data Scheme #

URI scheme to use

Constructors

Http | http://
Https | https://

#### Instances

Instances details

Data Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Scheme -> c Scheme # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Scheme # toConstr :: Scheme -> Constr # dataTypeOf :: Scheme -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Scheme) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Scheme) # gmapT :: (forall b. Data b => b -> b) -> Scheme -> Scheme # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Scheme -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Scheme -> r # gmapQ :: (forall d. Data d => d -> u) -> Scheme -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Scheme -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Scheme -> m Scheme #
Generic Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Associated Types
type Rep Scheme |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep Scheme = D1 ('MetaData "Scheme" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "Http" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Https" 'PrefixI 'False) (U1 :: Type -> Type))
Methods from :: Scheme -> Rep Scheme x # to :: Rep Scheme x -> Scheme #
Show Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> Scheme -> ShowS # show :: Scheme -> String # showList :: [Scheme] -> ShowS #
Eq Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods (==) :: Scheme -> Scheme -> Bool # (/=) :: Scheme -> Scheme -> Bool #
Ord Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods compare :: Scheme -> Scheme -> Ordering # (<) :: Scheme -> Scheme -> Bool # (<=) :: Scheme -> Scheme -> Bool # (>) :: Scheme -> Scheme -> Bool # (>=) :: Scheme -> Scheme -> Bool # max :: Scheme -> Scheme -> Scheme # min :: Scheme -> Scheme -> Scheme #
Lift Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods lift :: Quote m => Scheme -> m Exp # liftTyped :: forall (m :: Type -> Type). Quote m => Scheme -> Code m Scheme #
type Rep Scheme # |
Instance details Defined in Servant.Client.Core.BaseUrl type Rep Scheme = D1 ('MetaData "Scheme" "Servant.Client.Core.BaseUrl" "servant-client-core-0.20.2-JDs2vIfQ3Bk9wqlGzwnuNZ" 'False) (C1 ('MetaCons "Http" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Https" 'PrefixI 'False) (U1 :: Type -> Type))

showBaseUrl :: BaseUrl -> String #

    >>> showBaseUrl <$> parseBaseUrl "api.example.com"
    "http://api.example.com"

parseBaseUrl :: MonadThrow m => String -> m BaseUrl #

    >>> parseBaseUrl "api.example.com"
    BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = ""}

Note: trailing slash is removed

    >>> parseBaseUrl "api.example.com/"
    BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = ""}

    >>> parseBaseUrl "api.example.com/dir/"
    BaseUrl {baseUrlScheme = Http, baseUrlHost = "api.example.com", baseUrlPort = 80, baseUrlPath = "/dir"}

newtype InvalidBaseUrlException #

Constructors

InvalidBaseUrlException String |

#### Instances

Instances details

Exception InvalidBaseUrlException # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods toException :: InvalidBaseUrlException -> SomeException # fromException :: SomeException -> Maybe InvalidBaseUrlException # displayException :: InvalidBaseUrlException -> String # backtraceDesired :: InvalidBaseUrlException -> Bool #
Show InvalidBaseUrlException # |
Instance details Defined in Servant.Client.Core.BaseUrl Methods showsPrec :: Int -> InvalidBaseUrlException -> ShowS # show :: InvalidBaseUrlException -> String # showList :: [InvalidBaseUrlException] -> ShowS #

## Streaming

class RunClient m => RunStreamingClient (m :: Type -> Type) where #

Methods

withStreamingRequest :: Request -> (StreamingResponse -> IO a) -> m a #

type StreamingResponse = ResponseF (SourceIO ByteString) #

# Writing HasClient instances

These functions need not be re-exported by backend libraries.

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

Add header to the request being constructed.

appendToQueryString #

Arguments

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

Append a query parameter to the request being constructed.

appendToPath :: Builder -> Request -> Request #

Append extra path to the request being constructed.

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

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

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

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

Set body and media type of the request being constructed.

Since: 0.12

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

Encode a query parameter value.