git.iko.soy/typeable/servant
on release-0.11 help sign in
20 lines 677 B history raw
1# servant-client
3![servant](https://raw.githubusercontent.com/haskell-servant/servant/master/servant.png)
5This library lets you automatically derive Haskell functions that let you query each endpoint of a *servant* webservice.
7## Example
9``` haskell
10type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
11 :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books
13myApi :: Proxy MyApi
14myApi = Proxy
16getAllBooks :: Manager -> BaseUrl -> ExceptT String IO [Book]
17postNewBook :: Book -> Manager -> BaseUrl -> ExceptT String IO Book
18-- 'client' allows you to produce operations to query an API from a client.
19(getAllBooks :<|> postNewBook) = client myApi
20```