The apiary-http-client package

[ Tags: library, mit, web ] [ Propose Tags ]

A HTTP Client for 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.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0
Dependencies apiary (>=2.1 && <3.0), base (>=4.6 && <5.0), bytestring (==0.10.*), bytestring-builder (==0.10.*), http-client (==0.5.*), http-types (>=0.8), text (>=1.1 && <1.3), transformers (>=0.2 && <0.6), wai (>=3.0 && <3.3) [details]
License MIT
Author winterland
Maintainer winterland1989@gmail.com
Category Web
Home page https://github.com/winterland1989/apiary-http-client
Source repository head: git clone https://github.com/winterland1989/apiary-http-client.git
Uploaded Wed Nov 1 10:24:06 UTC 2017 by winterland
Distributions NixOS:0.1.4.0
Downloads 337 total (52 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-11-01 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for apiary-http-client-0.1.4.0

[back to package description]

Apiary HTTP Client

Hackage Travis-CI

A HTTP Client for 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

import Web.Apiary
import Network.Wai.Handler.Warp
import Web.Apiary.HTTP.Client as HTTP

main :: 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'