servant-client-0.15: Automatic derivation of querying functions for servant

Safe HaskellNone
LanguageHaskell2010

Servant.Client.Internal.HttpClient

Synopsis

Documentation

data ClientEnv Source #

The environment in which a request is run.

Constructors

ClientEnv 

Fields

Instances
MonadReader ClientEnv ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

MonadReader ClientEnv ClientM 
Instance details

Defined in Servant.Client.Internal.HttpClient.Streaming

mkClientEnv :: Manager -> BaseUrl -> ClientEnv Source #

ClientEnv smart constructor.

client :: HasClient ClientM api => Proxy api -> Client ClientM api Source #

Generates a set of client functions for an API.

Example:

type API = Capture "no" Int :> Get '[JSON] Int
       :<|> Get '[JSON] [Bool]

api :: Proxy API
api = Proxy

getInt :: Int -> ClientM Int
getBools :: ClientM [Bool]
getInt :<|> getBools = client api

hoistClient :: HasClient ClientM api => Proxy api -> (forall a. m a -> n a) -> Client m api -> Client n api Source #

Change the monad the client functions live in, by supplying a conversion function (a natural transformation to be precise).

For example, assuming you have some manager :: Manager and baseurl :: BaseUrl around:

type API = Get '[JSON] Int :<|> Capture "n" Int :> Post '[JSON] Int
api :: Proxy API
api = Proxy
getInt :: IO Int
postInt :: Int -> IO Int
getInt :<|> postInt = hoistClient api (flip runClientM cenv) (client api)
  where cenv = mkClientEnv manager baseurl

newtype ClientM a Source #

ClientM is the monad in which client functions run. Contains the Manager and BaseUrl used for requests in the reader environment.

Constructors

ClientM 

Fields

Instances
Monad ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

(>>=) :: ClientM a -> (a -> ClientM b) -> ClientM b

(>>) :: ClientM a -> ClientM b -> ClientM b

return :: a -> ClientM a

fail :: String -> ClientM a

Functor ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

fmap :: (a -> b) -> ClientM a -> ClientM b

(<$) :: a -> ClientM b -> ClientM a

Applicative ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

pure :: a -> ClientM a

(<*>) :: ClientM (a -> b) -> ClientM a -> ClientM b

liftA2 :: (a -> b -> c) -> ClientM a -> ClientM b -> ClientM c

(*>) :: ClientM a -> ClientM b -> ClientM b

(<*) :: ClientM a -> ClientM b -> ClientM a

MonadCatch ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

catch :: Exception e => ClientM a -> (e -> ClientM a) -> ClientM a

MonadThrow ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

throwM :: Exception e => e -> ClientM a

MonadIO ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

liftIO :: IO a -> ClientM a

Alt ClientM Source #

Try clients in order, last error is preserved.

Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

(<!>) :: ClientM a -> ClientM a -> ClientM a

some :: Applicative ClientM => ClientM a -> ClientM [a]

many :: Applicative ClientM => ClientM a -> ClientM [a]

RunClient ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

runRequest :: Request -> ClientM Response

throwServantError :: ServantError -> ClientM a

MonadBase IO ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

liftBase :: IO α -> ClientM α

MonadError ServantError ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

throwError :: ServantError -> ClientM a

catchError :: ClientM a -> (ServantError -> ClientM a) -> ClientM a

MonadReader ClientEnv ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

MonadBaseControl IO ClientM Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Associated Types

type StM ClientM a :: Type

Methods

liftBaseWith :: (RunInBase ClientM IO -> IO a) -> ClientM a

restoreM :: StM ClientM a -> ClientM a

Generic (ClientM a) Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Associated Types

type Rep (ClientM a) :: Type -> Type

Methods

from :: ClientM a -> Rep (ClientM a) x

to :: Rep (ClientM a) x -> ClientM a

ClientLike (ClientM a) (ClientM a) Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

Methods

mkClient :: ClientM a -> ClientM a

type StM ClientM a Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

type StM ClientM a = Either ServantError a
type Rep (ClientM a) Source # 
Instance details

Defined in Servant.Client.Internal.HttpClient

type Rep (ClientM a) = D1 (MetaData "ClientM" "Servant.Client.Internal.HttpClient" "servant-client-0.15-CSEQRKA8h3zE26iMoukBmO" True) (C1 (MetaCons "ClientM" PrefixI True) (S1 (MetaSel (Just "unClientM") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ReaderT ClientEnv (ExceptT ServantError IO) a))))

runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a) Source #

performRequest :: Request -> ClientM Response Source #

clientResponseToResponse :: Response a -> GenResponse a Source #

requestToClientRequest :: BaseUrl -> Request -> Request Source #

catchConnectionError :: IO a -> IO (Either ServantError a) Source #