servant/README.md

23 lines
920 B
Markdown
Raw Normal View History

2014-12-08 11:10:51 +01:00
# servant-client
[![Build Status](https://secure.travis-ci.org/haskell-servant/servant-client.svg)](http://travis-ci.org/haskell-servant/servant-client)
2015-02-19 20:48:52 +01:00
[![Coverage Status](https://coveralls.io/repos/haskell-servant/servant-client/badge.svg)](https://coveralls.io/r/haskell-servant/servant-client)
2014-12-08 11:10:51 +01:00
![servant](https://raw.githubusercontent.com/haskell-servant/servant/master/servant.png)
2015-02-06 09:34:59 +01:00
This library lets you automatically derive Haskell functions that let you query each endpoint of a *servant* webservice.
2014-12-08 11:10:51 +01:00
## Example
``` haskell
type MyApi = "books" :> Get [Book] -- GET /books
:<|> "books" :> ReqBody Book :> Post Book -- POST /books
myApi :: Proxy MyApi
myApi = Proxy
getAllBooks :: BaseUrl -> EitherT String IO [Book]
postNewBook :: Book -> BaseUrl -> EitherT String IO Book
-- 'client' allows you to produce operations to query an API from a client.
(getAllBooks :<|> postNewBook) = client myApi
```