webapi-0.2.0.0: WAI based library for web api

LicenseBSD3
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

WebApi.Client

Contents

Description

Provides a client for a web api for a given contract.

Synopsis

Client related functions

client :: (CookieOut m r ~ (), ToParam (PathParam m r) PathParam, ToParam (QueryParam m r) QueryParam, ToParam (FormParam m r) FormParam, ToHeader (HeaderIn m r), ToParam (FileParam m r) FileParam, FromHeader (HeaderOut m r), Decodings (ContentTypes m r) (ApiOut m r), Decodings (ContentTypes m r) (ApiErr m r), ParamErrToApiErr (ApiErr m r), SingMethod m, MkPathFormatString r) => ClientSettings -> Request m r -> IO (Response m r) Source

Given a Request type, create the request and obtain a response. Gives back a Response.

fromClientResponse :: forall m r. (FromHeader (HeaderOut m r), ParamErrToApiErr (ApiErr m r), Decodings (ContentTypes m r) (ApiOut m r), Decodings (ContentTypes m r) (ApiErr m r), CookieOut m r ~ ()) => Response BodyReader -> IO (Response m r) Source

Creates the Response type from the response body.

link :: (ToParam (QueryParam m r) QueryParam, MkPathFormatString r, ToParam (PathParam m r) PathParam) => route m r -> URI -> PathParam m r -> Maybe (QueryParam m r) -> URI Source

Generate a type safe URL for a given route type. The URI can be used for setting a base URL if required.

Types

data ClientSettings Source

Datatype representing the settings related to client.

Constructors

ClientSettings 

Fields

baseUrl :: String

base url of the API being called.

connectionManager :: Manager

connection manager for the connection.

data UnknownClientException Source

This exception is used to signal an irrecoverable error while deserializing the response.