c55b778d8e
- WIP: pending http-api-data release - TODO: remove MIN_VERSION_http_types - There have been 3 major releases of http-types: - 0.10 change name of variable - 0.11 lowercase escaped URIs - 0.12 uppercase escaped URIs - It's easier for us to support only latest, migration from 0.9/0.10 to 0.12 is trivial for the downstream. 0.11 may cause semantic (non-type-error) breakage somewhere. Also allow lens-4.16, remove MIN_VERSION_http_types conditionals, and update `stack.yaml` |
||
---|---|---|
.. | ||
include | ||
src/Servant | ||
test | ||
CHANGELOG.md | ||
docs.sh | ||
LICENSE | ||
README.md | ||
servant-client.cabal | ||
Setup.hs | ||
tinc.yaml |
servant-client
This library lets you automatically derive Haskell functions that let you query each endpoint of a servant webservice.
Example
type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
:<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books
myApi :: Proxy MyApi
myApi = Proxy
getAllBooks :: Manager -> BaseUrl -> ExceptT String IO [Book]
postNewBook :: Book -> Manager -> BaseUrl -> ExceptT String IO Book
-- 'client' allows you to produce operations to query an API from a client.
(getAllBooks :<|> postNewBook) = client myApi