3f905ea41c
CORS are rare. Most requests by far will be to the origin that served the javascript. |
||
---|---|---|
.. | ||
src/Servant/Client | ||
CHANGELOG.md | ||
LICENSE | ||
README.md | ||
servant-client-ghcjs.cabal | ||
Setup.hs | ||
tinc.yaml |
servant-client-ghcjs
This library lets you automatically derive Haskell functions that let you query each endpoint of a servant webservice. This library is specifically for ghcjs, as opposed to servant-client.
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