api-builder 0.7.4.0 → 0.8.0.0
raw patch · 3 files changed
+23/−11 lines, 3 filesdep ~bifunctorsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: bifunctors
API changes (from Hackage documentation)
+ Network.API.Builder.Send: PostQuery :: PostQuery
+ Network.API.Builder.Send: basicSend :: Builder -> Route -> Maybe Request
+ Network.API.Builder.Send: data PostQuery
+ Network.API.Builder.Send: instance Sendable PostQuery
+ Network.API.Builder.Send: instance Show PostQuery
Files
api-builder.cabal view
@@ -1,5 +1,5 @@ name: api-builder-version: 0.7.4.0+version: 0.8.0.0 synopsis: Library for easily building REST API wrappers in Haskell license: BSD3 license-file: LICENSE@@ -18,7 +18,7 @@ source-repository this type: git location: git://github.com/intolerable/api-builder.git- tag: v0.7.4.0+ tag: v0.8.0.0 library exposed-modules:@@ -36,7 +36,7 @@ base >= 4.6 && < 4.9, aeson >= 0.7 && < 0.9, attoparsec >= 0.11 && < 0.13,- bifunctors == 4.*,+ bifunctors >= 4.0 && < 6.0, bytestring == 0.10.*, either == 4.*, HTTP == 4000.*,
src/Network/API/Builder/API.hs view
@@ -77,7 +77,8 @@ liftIO $ closeManager m return res --- | Runs an @API@ by executing its transformer stack and dumping it all into @IO@. Returns the actual result as well as the final states of the @Builder@ and custom state @s@.+-- | Runs an @API@ by executing its transformer stack and dumping it all into @IO@.+-- | Returns the actual result as well as the final states of the @Builder@ and custom state @s@. runAPI :: MonadIO m => Builder -- ^ initial @Builder@ for the @API@ -> Manager -- ^ manager for working with conduit functions
src/Network/API/Builder/Send.hs view
@@ -22,24 +22,35 @@ , requestBody = RequestBodyBS (dropQuestion $ queryString req) , queryString = "" , method = httpMethod r }- _ -> do- req <- parseUrl $ Text.unpack $ routeURL (_baseURL builder) (_customizeRoute builder r)- return $ _customizeRequest builder $ req { method = httpMethod r }+ _ -> basicSend builder r where dropQuestion b = if ByteString.isPrefixOf "?" b then ByteString.drop 1 b else b +basicSend :: Builder -> Route -> Maybe Request+basicSend builder r = do+ req <- parseUrl $ Text.unpack $ routeURL (_baseURL builder) (_customizeRoute builder r)+ return $ _customizeRequest builder $ req { method = httpMethod r }+ instance Sendable Value where send builder r value = case httpMethod r of "POST" -> do- req <- send builder r ()- return $ req { requestBody = RequestBodyLBS (encode value)- , requestHeaders = ("Content-Type", "application/json") : requestHeaders req }+ req <- parseUrl $ Text.unpack $ routeURL (_baseURL builder) (_customizeRoute builder r)+ return $ _customizeRequest builder $+ req { requestBody = RequestBodyLBS (encode value)+ , requestHeaders = ("Content-Type", "application/json") : requestHeaders req+ , method = httpMethod r } _ -> Nothing instance Sendable ByteString where send builder r bs = case httpMethod r of "POST" -> do- req <- send builder r ()+ req <- basicSend builder r return $ req { requestBody = RequestBodyLBS bs } _ -> Nothing++data PostQuery = PostQuery+ deriving (Show)++instance Sendable PostQuery where+ send builder r PostQuery = basicSend builder r