packages feed

apiary-http-client 0.1.1.0 → 0.1.2.0

raw patch · 3 files changed

+37/−13 lines, 3 filesdep +bytestring-builderdep ~basedep ~bytestringdep ~http-clientPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring-builder

Dependency ranges changed: base, bytestring, http-client, text, transformers, wai

API changes (from Hackage documentation)

+ Web.Apiary.HTTP.Client: forwardBadStatus :: (Has HTTPClient exts, MonadIO m) => HttpException -> ActionT exts prms m ()
+ Web.Apiary.HTTP.Client: forwardBadStatus' :: (Has HTTPClient exts, MonadIO m) => HttpException -> ActionT exts prms m ()

Files

README.md view
@@ -1,7 +1,8 @@ Apiary HTTP Client ================== -[![Hackage](https://img.shields.io/hackage/v/apiary-http-client.svg?style=flat-square)](http://hackage.haskell.org/package/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. @@ -16,7 +17,7 @@ import Web.Apiary.HTTP.Client as HTTP  main :: IO ()-main = runApiaryWith (run serverPort) (HTTP.initHTTPClient HTTP.defaultManagerSettings) def $ do+main = runApiaryWith (run 8080) (HTTP.initHTTPClient HTTP.defaultManagerSettings) def $ do      [capture|/query|] . action $ do         
Web/Apiary/HTTP/Client.hs view
@@ -30,13 +30,18 @@     -- ** Send request and proxy respond     , proxyTo     , proxyWith+    -- http client exception handler+    , forwardBadStatus+    , forwardBadStatus'     , module Network.HTTP.Client     ) where  import Control.Monad.IO.Class+import Control.Exception (throwIO) import Network.HTTP.Client import qualified Network.Wai as W import Network.HTTP.Types.Header+import Network.HTTP.Types.Status (notFound404) import Data.Apiary.Extension import qualified Data.Proxy.Compat as P (Proxy(..)) import Unsafe.Coerce (unsafeCoerce)@@ -175,3 +180,20 @@     A.status (responseStatus resLbs')     A.setHeaders (responseHeaders resLbs')     A.lazyBytes (responseBody resLbs')++-- |A catch handler which only deal with 'StatusCodeException'+--  the status code will be proxy to user.+--  any other exceptions will be re-thrown.+--  It's intend to use with MonadCatch or MonadBaseControl instance of 'ActionT'+forwardBadStatus :: (Has HTTPClient exts, MonadIO m)+    => HttpException -> A.ActionT exts prms m ()+forwardBadStatus (StatusCodeException s h _) = A.status s >> A.stop+forwardBadStatus err = liftIO $ throwIO err++-- |same with 'forwardBadStatus', except that+--  any other exceptions will be result in a 404 status with exceptions message.+--  It's intend to use with MonadCatch or MonadBaseControl instance of 'ActionT'+forwardBadStatus' :: (Has HTTPClient exts, MonadIO m)+    => HttpException -> A.ActionT exts prms m ()+forwardBadStatus' (StatusCodeException s h _) = A.status s >> A.stop+forwardBadStatus' err = A.status notFound404 >> A.showing err >> A.stop
apiary-http-client.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                apiary-http-client-version:             0.1.1.0+version:             0.1.2.0 synopsis:            A http client for Apiary. description:              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.@@ -25,16 +25,17 @@ library     exposed-modules:     Web.Apiary.HTTP.Client     -- other-modules:       -    build-depends:        base >=4.8 && <4.9-                          ,   transformers-                          ,   types-compat                >=0.1   && <0.2-                          ,   http-client                 >=0.4.26-                          ,   http-types                  >=0.8-                          ,   apiary                      >=1.0.0-                          ,   wai-                          ,   data-default-class-                          ,   bytestring-                          ,   text+    build-depends:        base                        >=4.6 && <4.9+                      ,   transformers                >=0.2   && <0.5+                      ,   types-compat                >=0.1   && <0.2+                      ,   http-client                 >=0.4+                      ,   http-types                  >=0.8+                      ,   apiary                      >=1.4   && <3.0+                      ,   wai                         >=3.0   && <3.3+                      ,   data-default-class+                      ,   bytestring                  >=0.10  && <0.11+                      ,   bytestring-builder          >=0.10  && <0.11+                      ,   text                        >=1.1   && <1.3     -- hs-source-dirs:           default-language:    Haskell2010