apiary-http-client: A http client for Apiary.

[ library, mit, web ] [ Propose Tags ] [ Report a vulnerability ]

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]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 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 && <0.11), bytestring-builder (>=0.10 && <0.11), http-client (>=0.5 && <0.6), 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 repo head: git clone https://github.com/winterland1989/apiary-http-client.git
Uploaded by winterland at 2017-11-01T10:24:06Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3978 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-11-01 [all 1 reports]

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'