packages feed

http-query 0.1.2 → 0.1.3

raw patch · 4 files changed

+33/−32 lines, 4 filesdep −http-clientdep −http-client-tlsPVP ok

version bump matches the API change (PVP)

Dependencies removed: http-client, http-client-tls

API changes (from Hackage documentation)

+ Network.HTTP.Query: withURLQuery :: String -> Query -> (Request -> a) -> a

Files

ChangeLog.md view
@@ -1,5 +1,8 @@ # Revision history for http-query +## 0.1.3 (2022-02-17)+- new withURLQuery setup function+ ## 0.1.2 (2022-02-17) - webAPIQuery: revert to not using setRequestCheckStatus 
README.md view
@@ -11,10 +11,10 @@  A few projects use http-query already: -- https://hackage.haskell.org/package/cached-json-file-- https://hackage.haskell.org/package/fbrnch-- https://hackage.haskell.org/package/stack-all-- https://hackage.haskell.org/package/bodhi-- https://hackage.haskell.org/package/copr-api-- https://hackage.haskell.org/package/pagure-- https://hackage.haskell.org/package/pdc+- <https://hackage.haskell.org/package/cached-json-file>+- <https://hackage.haskell.org/package/fbrnch>+- <https://hackage.haskell.org/package/stack-all>+- <https://hackage.haskell.org/package/bodhi>+- <https://hackage.haskell.org/package/copr-api>+- <https://hackage.haskell.org/package/pagure>+- <https://hackage.haskell.org/package/pdc>
http-query.cabal view
@@ -1,5 +1,5 @@ name:                http-query-version:             0.1.2+version:             0.1.3 synopsis:            Simple http queries description:         Simple web API queries returning JSON.@@ -29,13 +29,9 @@                      , text   if impl(ghc < 8)     build-depends:     transformers-  if impl(ghc<8.3)-    build-depends:-                       http-client < 0.7.11 || > 0.7.11,-                       http-client-tls < 0.3.6 || > 0.3.6   exposed-modules:     Network.HTTP.Query   hs-source-dirs:      src-+  default-language:    Haskell2010   ghc-options:         -Wall   if impl(ghc >= 8.0)     ghc-options:       -Wcompat@@ -48,5 +44,3 @@   if impl(ghc >= 8.4)     ghc-options:       -Wmissing-export-lists                        -Wpartial-fields--  default-language:    Haskell2010
src/Network/HTTP/Query.hs view
@@ -23,14 +23,18 @@ -}  module Network.HTTP.Query (+  -- * Queries+  withURLQuery,+  webAPIQuery,+  apiQueryURI,+  (+/+),+  -- * Query parameters   Query,   QueryItem,   maybeKey,   makeKey,   makeItem,-  (+/+),-  webAPIQuery,-  apiQueryURI,+  -- * Lookup fields   lookupKey,   lookupKeyEither,   lookupKey'@@ -86,30 +90,30 @@         | head t == '/' = s ++ t s +/+ t = s ++ '/' : t --- | Low-level web api query-webAPIQuery :: (MonadIO m, FromJSON a)-            => String -- ^ url of endpoint-            -> Query -- ^ query options-            -> m a -- ^ returned json-webAPIQuery url params =+-- | Sets up an API request for some action+withURLQuery :: String -> Query -> (Request -> a) -> a+withURLQuery url params act =   case parseURI url of     Nothing -> error $ "Cannot parse uri: " ++ url     Just uri ->       let req = setRequestQueryString params $                 requestFromURI_ uri-      in getResponseBody <$> httpJSON req+      in act req +-- | Low-level web api query+webAPIQuery :: (MonadIO m, FromJSON a)+            => String -- ^ URL of endpoint+            -> Query -- ^ query options+            -> m a -- ^ returned JSON+webAPIQuery url params =+  withURLQuery url params $ fmap getResponseBody . httpJSON+ -- | Get the URI for a web query-apiQueryURI :: String -- ^ url of endpoint+apiQueryURI :: String -- ^ URL of endpoint             -> Query -- ^ query options             -> URI apiQueryURI url params =-  case parseURI url of-    Nothing -> error $ "Cannot parse uri: " ++ url-    Just uri ->-      let req = setRequestQueryString params $-                requestFromURI_ uri-      in getUri req+  withURLQuery url params getUri  -- FIXME support "key1.key2" etc -- | Look up key in object