hreq-core-0.1.0.0: Core functionality for Hreq Http client library

Safe HaskellNone
LanguageHaskell2010

Hreq.Core.Client.Internal

Description

This module provides functions that take API endpoint types and transform them into HTTP Response outputs.

Synopsis

Documentation

type HasClient api ts v n m = (ts ~ ApiToReq api, v ~ GetVerb api, HasRequest ts v, HasResponse v n, MonadError ClientError n, RunClient m) Source #

HasClient represent constraints required to interpret a type level API into an actual HTTP network request.

ts ~ ApiToReq api : Turns API description into a list of Request Content types

v ~ GetVerb api : Retrieves the verb component of an API definition

HasRequest ts v : Interprets type level list ReqContent and Verb components to obtain RequestF Data

HasResponse v n : Interprets Verb component to obtain type level specified Response

MonadError ClientError n : MonadError ClientError n is used by the httpRes function

RunClient m : Provides capability to make an actual Http client network request

hreq' :: forall api ts v m. HasClient api ts v (Either ClientError) m => Proxy api -> HttpInput ts -> m (HttpOutput v) Source #

Used to make generic HTTP requests

hreq :: forall api ts v m. HasClient api ts v (Either ClientError) m => HttpInput ts -> m (HttpOutput v) Source #

Used to make HTTP requests. Uses visible type-applications for API type specification. Example

hreq @(Capture "age" Int :> GetJson Value) (25 :. Empty)

type HasStreamingClient api a ts v m = (ts ~ ApiToReq api, v ~ GetVerb api, HasRequest ts v, RunStreamingClient m a) Source #

HasStreamingClient type constraint is represents constraints required for streaming HTTP responses.

ts ~ ApiToReq api : Turns API description into a list of Request Content types

v ~ GetVerb api : Retrieves the verb component of an API definition

HasRequest ts v : Interprets type level list ReqContent and Verb components to obtain

RunStreamingClient m a: Provides capability to create an HTTP request with response streaming.

hreqStream :: forall api a ts v m r. HasStreamingClient api a ts v m => Proxy api -> HttpInput ts -> (a -> IO r) -> m r Source #

Helper function for working with an HTTP response streaming client.