Rename EmptyAPIClient to EmptyClient
This commit is contained in:
parent
f5d9983381
commit
0bbc4f98a4
3 changed files with 8 additions and 10 deletions
|
@ -77,8 +77,6 @@ hello :: Maybe String -- ^ an optional value for "name"
|
||||||
|
|
||||||
marketing :: ClientInfo -- ^ value for the request body
|
marketing :: ClientInfo -- ^ value for the request body
|
||||||
-> ClientM Email
|
-> ClientM Email
|
||||||
|
|
||||||
emptyClient :: EmptyAPIClient
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Each function makes available as an argument any value that the response may
|
Each function makes available as an argument any value that the response may
|
||||||
|
@ -91,7 +89,7 @@ the function `client`. It takes one argument:
|
||||||
api :: Proxy API
|
api :: Proxy API
|
||||||
api = Proxy
|
api = Proxy
|
||||||
|
|
||||||
position :<|> hello :<|> marketing :<|> emptyClient = client api
|
position :<|> hello :<|> marketing :<|> EmptyClient = client api
|
||||||
```
|
```
|
||||||
|
|
||||||
`client api` returns client functions for our _entire_ API, combined with `:<|>`, which we can pattern match on as above. You could say `client` "calculates" the correct type and number of client functions for the API type it is given (via a `Proxy`), as well as their implementations.
|
`client api` returns client functions for our _entire_ API, combined with `:<|>`, which we can pattern match on as above. You could say `client` "calculates" the correct type and number of client functions for the API type it is given (via a `Proxy`), as well as their implementations.
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Servant.Client
|
||||||
, ClientEnv (ClientEnv)
|
, ClientEnv (ClientEnv)
|
||||||
, mkAuthenticateReq
|
, mkAuthenticateReq
|
||||||
, ServantError(..)
|
, ServantError(..)
|
||||||
, EmptyAPIClient(..)
|
, EmptyClient(..)
|
||||||
, module Servant.Common.BaseUrl
|
, module Servant.Common.BaseUrl
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
|
||||||
clientWithRoute (Proxy :: Proxy b) req
|
clientWithRoute (Proxy :: Proxy b) req
|
||||||
|
|
||||||
-- | Singleton type representing a client for an empty API.
|
-- | Singleton type representing a client for an empty API.
|
||||||
data EmptyAPIClient = EmptyAPIClient
|
data EmptyClient = EmptyClient deriving (Eq, Show, Bounded, Enum)
|
||||||
|
|
||||||
-- | The client for 'EmptyAPI' is simply 'EmptyAPIClient'.
|
-- | The client for 'EmptyAPI' is simply 'EmptyClient'.
|
||||||
--
|
--
|
||||||
-- > type MyAPI = "books" :> Get '[JSON] [Book] -- GET /books
|
-- > type MyAPI = "books" :> Get '[JSON] [Book] -- GET /books
|
||||||
-- > :<|> "nothing" :> EmptyAPI
|
-- > :<|> "nothing" :> EmptyAPI
|
||||||
|
@ -101,10 +101,10 @@ data EmptyAPIClient = EmptyAPIClient
|
||||||
-- > myApi = Proxy
|
-- > myApi = Proxy
|
||||||
-- >
|
-- >
|
||||||
-- > getAllBooks :: ClientM [Book]
|
-- > getAllBooks :: ClientM [Book]
|
||||||
-- > (getAllBooks :<|> EmptyAPIClient) = client myApi
|
-- > (getAllBooks :<|> EmptyClient) = client myApi
|
||||||
instance HasClient EmptyAPI where
|
instance HasClient EmptyAPI where
|
||||||
type Client EmptyAPI = EmptyAPIClient
|
type Client EmptyAPI = EmptyClient
|
||||||
clientWithRoute Proxy _ = EmptyAPIClient
|
clientWithRoute Proxy _ = EmptyClient
|
||||||
|
|
||||||
-- | If you use a 'Capture' in one of your endpoints in your API,
|
-- | If you use a 'Capture' in one of your endpoints in your API,
|
||||||
-- the corresponding querying function will automatically take
|
-- the corresponding querying function will automatically take
|
||||||
|
|
|
@ -146,7 +146,7 @@ getGet
|
||||||
:<|> getMultiple
|
:<|> getMultiple
|
||||||
:<|> getRespHeaders
|
:<|> getRespHeaders
|
||||||
:<|> getDeleteContentType
|
:<|> getDeleteContentType
|
||||||
:<|> EmptyAPIClient = client api
|
:<|> EmptyClient = client api
|
||||||
|
|
||||||
server :: Application
|
server :: Application
|
||||||
server = serve api (
|
server = serve api (
|
||||||
|
|
Loading…
Reference in a new issue