servant-client-0.13: automatical derivation of querying functions for servant webservices

Safe HaskellNone
LanguageHaskell2010

Servant.Client

Description

This module provides client which can automatically generate querying functions for each endpoint just from the type representing your API.

Synopsis

Documentation

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

data ClientM a Source #

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

Instances

Monad ClientM Source # 

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 # 

Methods

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

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

Applicative ClientM Source # 

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 #

MonadIO ClientM Source # 

Methods

liftIO :: IO a -> ClientM a #

MonadThrow ClientM Source # 

Methods

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

MonadCatch ClientM Source # 

Methods

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

Alt ClientM Source #

Try clients in order, last error is preserved.

RunClient ClientM Source # 
MonadBase IO ClientM Source # 

Methods

liftBase :: IO α -> ClientM α #

MonadBaseControl IO ClientM Source # 

Associated Types

type StM (ClientM :: * -> *) a :: * #

MonadReader ClientEnv ClientM Source # 

Methods

ask :: ClientM ClientEnv #

local :: (ClientEnv -> ClientEnv) -> ClientM a -> ClientM a #

reader :: (ClientEnv -> a) -> ClientM a #

MonadError ServantError ClientM Source # 
Generic (ClientM a) Source # 

Associated Types

type Rep (ClientM a) :: * -> * #

Methods

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

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

ClientLike (ClientM a) (ClientM a) Source # 

Methods

mkClient :: ClientM a -> ClientM a #

type StM ClientM a Source # 
type Rep (ClientM a) Source # 
type Rep (ClientM a) = D1 * (MetaData "ClientM" "Servant.Client.Internal.HttpClient" "servant-client-0.13-1qaZDqIeaLjHfjsSytF1lK" True) (C1 * (MetaCons "ClientM" PrefixI True) (S1 * (MetaSel (Just Symbol "unClientM") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (ReaderT * ClientEnv (ExceptT ServantError IO) a))))

data ClientEnv Source #

The environment in which a request is run.