Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/winterland1989/apiary-http-client
A http client for Apiary's ActionT monad stack.
https://github.com/winterland1989/apiary-http-client
Last synced: 9 days ago
JSON representation
A http client for Apiary's ActionT monad stack.
- Host: GitHub
- URL: https://github.com/winterland1989/apiary-http-client
- Owner: winterland1989
- License: mit
- Created: 2016-03-15T08:43:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-01T09:57:10.000Z (about 7 years ago)
- Last Synced: 2023-09-20T05:32:32.563Z (about 1 year ago)
- Language: Haskell
- Size: 11.7 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Apiary HTTP Client
==================[![Hackage](https://img.shields.io/hackage/v/apiary-http-client.svg?style=flat)](http://hackage.haskell.org/package/apiary-http-client)
[![Travis-CI](https://travis-ci.org/winterland1989/apiary-http-client.svg)](https://travis-ci.org/winterland1989/apiary-http-client)A HTTP Client for [Apiary](http://hackage.haskell.org/package/apiary), using `Apiary`'s extension api, suitable for proxying HTTP request to backend API, with flexible APIs and streamming proxying abilities.
This module also reexport `Network.HTTP.Client`.
Example
-------```haskell
import Web.Apiary
import Network.Wai.Handler.Warp
import Web.Apiary.HTTP.Client as HTTPmain :: IO ()
main = runApiaryWith (run 8080) (HTTP.initHTTPClient HTTP.defaultManagerSettings) def $ do[capture|/query|] . action $ do
-- make a new Network.HTTP.Client.Request from current ActionT's Network.Wai.Request
-- it's recommended to use resetHeaders to remove following headers:
-- Transfer-Encoding, Content-Length, Content-Encoding and Accept-Encoding.
req <- HTTP.fromRequest id resetHeaders-- set proxying host and port
-- use function from Network.HTTP.Client to modify more
let req' = HTTP.setHost "api.backend.com" . HTTP.setPort 80 $ req-- send request and proxy respond in streamming fashion.
HTTP.proxyTo req'
```