@@ -1,4 +1,3 @@
1−{-# LANGUAGE AllowAmbiguousTypes #-}
2{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
3{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
@@ -17,23 +16,34 @@
17-- querying functions for each endpoint just from the type representing your
16-- querying functions for each endpoint just from the type representing your
19module Servant.Client.Core
18module Servant.Client.Core
20− ( AuthClientData
19+ (
21− , AuthenticateReq(..)
20+ -- * Client generation
22− , clientIn
21+ clientIn
23 , HasClient(..)
22 , HasClient(..)
24 , mkAuthenticateReq
25 , mkAuthenticateReq
26+ , AuthenticateReq(..)
25 , ServantError(..)
33 , ServantError(..)
26 , EmptyClient(..)
34 , EmptyClient(..)
28 , Request(..)
37 , Request(..)
29 , defaultRequest
38 , defaultRequest
31 , RequestBody(..)
39 , RequestBody(..)
32 , module Servant.Client.Core.Internal.BaseUrl
44 , module Servant.Client.Core.Internal.BaseUrl
36− -- * Writing instances
46+ -- * Writing HasClient instances
37 , addHeader
47 , addHeader
38 , appendToQueryString
48 , appendToQueryString
39 , appendToPath
49 , appendToPath
@@ -84,13 +94,13 @@ import Servant.Client.Core.Internal.BaseUrl (BaseUrl (..),
84 showBaseUrl)
94 showBaseUrl)
85import Servant.Client.Core.Internal.BasicAuth
95import Servant.Client.Core.Internal.BasicAuth
86import Servant.Client.Core.Internal.Class
96import Servant.Client.Core.Internal.Class
87−import Servant.Client.Core.Internal.Request
88import Servant.Client.Core.Internal.Generic
97import Servant.Client.Core.Internal.Generic
98+import Servant.Client.Core.Internal.Request
90-- * Accessing APIs as a Client
100-- * Accessing APIs as a Client
92−-- | 'client' allows you to produce operations to query an API from a client within
102+-- | 'clientIn' allows you to produce operations to query an API from a client
93−-- a given monadic context `m`
103+-- within a 'RunClient' monad.
95-- > type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
105-- > type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
96-- > :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book -- POST /books
106-- > :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book -- POST /books
@@ -108,9 +118,12 @@ clientIn :: HasClient m api => Proxy api -> Proxy m -> Client m api
108clientIn p pm = clientWithRoute pm p defaultRequest
118clientIn p pm = clientWithRoute pm p defaultRequest
111−-- | This class lets us define how each API combinator
121+-- | This class lets us define how each API combinator influences the creation
112−-- influences the creation of an HTTP request. It's mostly
122+-- of an HTTP request.
113−-- an internal class, you can just use 'client'.
123+--
124+-- Unless you are writing a new backend for @servant-client-core@ or new
125+-- combinators that you want to support client-generation, you can ignore this
114class RunClient m => HasClient m api where
127class RunClient m => HasClient m api where
115 type Client (m :: * -> *) (api :: *) :: *
128 type Client (m :: * -> *) (api :: *) :: *
116 clientWithRoute :: Proxy m -> Proxy api -> Request -> Client m api
129 clientWithRoute :: Proxy m -> Proxy api -> Request -> Client m api