License | BSD3 |
---|---|
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Provides a client for a web api for a given contract.
- client :: forall m r. (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), SingMethod m, MkPathFormatString r, PartEncodings (RequestBody m r), ToHListRecTuple (StripContents (RequestBody m r))) => ClientSettings -> Request m r -> IO (Response m r)
- fromClientResponse :: forall m r. (FromHeader (HeaderOut 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)
- toClientRequest :: forall 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, SingMethod m, MkPathFormatString r, PartEncodings (RequestBody m r), ToHListRecTuple (StripContents (RequestBody m r))) => Request -> Request m r -> IO Request
- 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
- data ClientSettings = ClientSettings {}
- data UnknownClientException
- data Manager :: *
- newManager :: ManagerSettings -> IO Manager
- closeManager :: Manager -> IO ()
- withManager :: ManagerSettings -> (Manager -> IO a) -> IO a
- class HasHttpManager a where
- getHttpManager :: a -> Manager
- data ManagerSettings :: *
- defaultManagerSettings :: ManagerSettings
- tlsManagerSettings :: ManagerSettings
Client related functions
client :: forall m r. (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), SingMethod m, MkPathFormatString r, PartEncodings (RequestBody m r), ToHListRecTuple (StripContents (RequestBody m r))) => ClientSettings -> Request m r -> IO (Response m r) Source
fromClientResponse :: forall m r. (FromHeader (HeaderOut 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.
toClientRequest :: forall 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, SingMethod m, MkPathFormatString r, PartEncodings (RequestBody m r), ToHListRecTuple (StripContents (RequestBody m r))) => Request -> Request m r -> IO Request Source
Creates a request from the Request
type.
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.
ClientSettings | |
|
data UnknownClientException Source
This exception is used to signal an irrecoverable error while deserializing the response.
Connection manager
data Manager :: *
Keeps track of open connections for keep-alive.
If possible, you should share a single Manager
between multiple threads and requests.
Since 0.1.0
newManager :: ManagerSettings -> IO Manager
Create a Manager
. The Manager
will be shut down automatically via
garbage collection.
Creating a new Manager
is a relatively expensive operation, you are
advised to share a single Manager
between requests instead.
The first argument to this function is often defaultManagerSettings
,
though add-on libraries may provide a recommended replacement.
Since 0.1.0
closeManager :: Manager -> IO ()
Close all connections in a Manager
.
Note that this doesn't affect currently in-flight connections, meaning you can safely use it without hurting any queries you may have concurrently running.
Since 0.1.0
withManager :: ManagerSettings -> (Manager -> IO a) -> IO a
Create, use and close a Manager
.
Since 0.2.1
Connection manager settings
data ManagerSettings :: *
Settings for a Manager
. Please use the defaultManagerSettings
function and then modify
individual settings. For more information, see http://www.yesodweb.com/book/settings-types.
Since 0.1.0
defaultManagerSettings :: ManagerSettings
Default value for ManagerSettings
.
Note that this value does not have support for SSL/TLS. If you need to
make any https connections, please use the http-client-tls package, which
provides a tlsManagerSettings
value.
Since 0.1.0
tlsManagerSettings :: ManagerSettings
Default TLS-enabled manager settings