network-api-support 0.1.0 → 0.2.0
raw patch · 3 files changed
+30/−17 lines, 3 filesdep ~aesondep ~attoparsecdep ~bytestring
Dependency ranges changed: aeson, attoparsec, bytestring, case-insensitive, http-client, http-client-tls, http-types, text, time, tls
Files
- network-api-support.cabal +14/−14
- src/Network/Api/Support/Request.hs +8/−3
- src/Network/Api/Support/Response.hs +8/−0
network-api-support.cabal view
@@ -1,5 +1,5 @@ Name: network-api-support-Version: 0.1.0+Version: 0.2.0 License: BSD3 License-File: LICENSE Author: Mark Hibberd <mark@hibberd.id.au>@@ -7,8 +7,8 @@ Copyright: (c) 2012 Mark Hibberd Synopsis: Toolkit for building http client libraries over Network.Http.Conduit Category: Network APIs-Homepage: https://github.com/apiengine/network-api-support-Bug-reports: https://github.com/apiengine/network-api-support/issues+Homepage: https://github.com/markhibberd/network-api-support+Bug-reports: https://github.com/markhibberd/network-api-support/issues Cabal-Version: >= 1.8 Build-Type: Simple Description:@@ -20,7 +20,7 @@ Source-Repository head Type: git- Location: https://github.com/apiengine/network-api-support.git+ Location: https://github.com/markhibberd/network-api-support.git Flag small_base Description: Choose the new, split-up base package.@@ -28,16 +28,16 @@ Library Build-Depends: base >= 3 && < 5- , aeson >= 0.5- , attoparsec >= 0.10- , bytestring >= 0.9- , case-insensitive >= 0.4- , http-types >= 0.6- , http-client >= 0.2.2.2- , http-client-tls >= 0.2.1.1- , text >= 0.11- , time >= 1- , tls >= 1.2.2+ , aeson >= 0.5 && < 0.9+ , attoparsec >= 0.10 && < 0.13+ , bytestring >= 0.9.1.5 && < 0.11+ , case-insensitive >= 0.2 && < 1.3+ , http-types >= 0.6 && < 0.9+ , http-client >= 0.2.2.2 && < 0.5+ , http-client-tls >= 0.2.1.1 && < 0.3+ , text >= 0.11 && < 1.3+ , time == 1.*+ , tls == 1.2.* GHC-Options: -Wall -fno-warn-orphans
src/Network/Api/Support/Request.hs view
@@ -2,7 +2,8 @@ module Network.Api.Support.Request ( RequestTransformer , setApiKey-, setParams+, setUrlEncodedBody+, setQueryParams , setHeaders , setHeader , addHeader@@ -35,9 +36,13 @@ setApiKey :: B.ByteString -> RequestTransformer setApiKey key = Endo $ applyBasicAuth key "" +-- | Set URL encoded form params on the request body.+setUrlEncodedBody :: [(B.ByteString, B.ByteString)] -> RequestTransformer+setUrlEncodedBody = Endo . urlEncodedBody+ -- | Set request query parameters.-setParams :: [(B.ByteString, B.ByteString)] -> RequestTransformer-setParams params = Endo $ urlEncodedBody params+setQueryParams :: [(B.ByteString, Maybe B.ByteString)] -> RequestTransformer+setQueryParams = Endo . setQueryString -- | Set request headers. setHeaders :: [(CI B.ByteString, B.ByteString)] -> RequestTransformer
src/Network/Api/Support/Response.hs view
@@ -6,6 +6,7 @@ , basicResponder ) where +import Control.Applicative import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL import Data.Attoparsec.Lazy@@ -27,6 +28,13 @@ fmap _ (ParseError t) = ParseError t fmap _ (DecodeError t) = DecodeError t fmap f (JsonSuccess a) = JsonSuccess $ f a++instance Applicative JsonResult where + pure = JsonSuccess++ (JsonSuccess f) <*> m = fmap f m+ (ParseError err) <*> _ = ParseError err+ (DecodeError err) <*> _ = DecodeError err instance Monad JsonResult where return = JsonSuccess