servant-client-0.12.0.1: 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 #

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 #

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

Instances

Monad ClientM # 

Methods

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

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

return :: a -> ClientM a #

fail :: String -> ClientM a #

Functor ClientM # 

Methods

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

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

Applicative ClientM # 

Methods

pure :: a -> ClientM a #

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

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

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

MonadIO ClientM # 

Methods

liftIO :: IO a -> ClientM a #

MonadThrow ClientM # 

Methods

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

MonadCatch ClientM # 

Methods

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

RunClient ClientM # 
Alt ClientM #

Try clients in order, last error is preserved.

MonadBase IO ClientM # 

Methods

liftBase :: IO α -> ClientM α #

MonadBaseControl IO ClientM # 

Associated Types

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

MonadError ServantError ClientM # 
MonadReader ClientEnv ClientM # 

Methods

ask :: ClientM ClientEnv #

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

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

Generic (ClientM a) # 

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) # 

Methods

mkClient :: ClientM a -> ClientM a #

type StM ClientM a # 
type Rep (ClientM a) # 
type Rep (ClientM a) = D1 (MetaData "ClientM" "Servant.Client.Internal.HttpClient" "servant-client-0.12.0.1-3yPDo9Grin66SHcZTMg5ue" True) (C1 (MetaCons "ClientM" PrefixI True) (S1 (MetaSel (Just Symbol "runClientM'") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ReaderT * ClientEnv (ExceptT ServantError IO) a))))

data ClientEnv #

The environment in which a request is run.

Constructors

ClientEnv 

Fields