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

[ 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]
Versions [RSS] [faq] 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0
Dependencies apiary (>=1.4 && <3.0), base (==4.8.*), bytestring, data-default-class, http-client (>=0.4.26), http-types (>=0.8), text, transformers, types-compat (==0.1.*), wai [details]
License MIT
Author winterland
Maintainer winterland1989@gmail.com
Revised Revision 2 made by winterland at 2016-03-28T03:25:47Z
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 2016-03-16T02:48:23Z
Distributions NixOS:0.1.4.0
Downloads 3513 total (31 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2016-03-16 [all 1 reports]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for apiary-http-client-0.1.1.0

[back to package description]

Apiary HTTP Client

Hackage

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 serverPort) (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'