http-barf 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+23/−5 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Network.HTTP.Barf.Internal: buildRequestFromReq :: String -> String -> Req' -> IO Request
+ Network.HTTP.Barf.Internal: buildRequestFromReq :: StrictByteString -> String -> Req' -> IO Request
- Network.HTTP.Barf.Internal: httpWithManager :: MonadIO m => String -> String -> Req -> m LazyByteString
+ Network.HTTP.Barf.Internal: httpWithManager :: MonadIO m => StrictByteString -> String -> Req -> m LazyByteString
Files
- CHANGELOG.md +4/−0
- README.md +13/−1
- http-barf.cabal +2/−1
- src/Network/HTTP/Barf/Internal.hs +4/−3
CHANGELOG.md view
@@ -3,3 +3,7 @@ ## 0.1.0.0 -- 2024-07-21 * initial support for sending simple http requests with monoidal interface++## 0.1.1.0 -- 2024-07-21++* internall, don't do unnecessary conversion from String to StrictByteString and use StrictByteString directly
README.md view
@@ -1,4 +1,4 @@-[](https://ci.mangoiv.com/repos/11)+[](https://hackage.haskell.org/package/http-barf) [](https://ci.mangoiv.com/repos/11) # http barf @@ -8,3 +8,15 @@ You may use it if you just have to vomit out a quick script and don't want to deal with all the complexities of involving a library that provides more features or more safety guarantees.++## Example ++```haskell+λ GHCi ~ res <- get_ "https://jsonplaceholder.typicode.com/posts" [q_ "userId" "1"]+res :: Data.ByteString.Lazy.Internal.LazyByteString+(0.40 secs, 6,838,760 bytes)+λ GHCi ~ decode @Value res +Just (Array [Object (fromList [("body",String "quia et suscipit\nsuscipit ...+it :: Maybe Value+(0.01 secs, 3,324,080 bytes)+```
http-barf.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.4 name: http-barf-version: 0.1.0.0+version: 0.1.1.0 synopsis: a library to make http requests without worrying much description: a dead simple library to make http requests. It provides helper functions to use different http methods, it supports @@ -47,6 +47,7 @@ DataKinds DerivingVia OverloadedRecordDot+ OverloadedStrings TypeFamilies test-suite http-barf-test
src/Network/HTTP/Barf/Internal.hs view
@@ -27,6 +27,7 @@ import Control.Monad.IO.Class (MonadIO (liftIO)) import Data.Aeson (Value) import Data.Aeson qualified as Aeson+import Data.ByteString (StrictByteString) import Data.ByteString.Char8 qualified as BS8 import Data.ByteString.Lazy (LazyByteString) import Data.List qualified as List@@ -134,12 +135,12 @@ -> m LazyByteString post_ = httpWithManager "POST" -buildRequestFromReq :: String -> String -> Req' -> IO Request+buildRequestFromReq :: StrictByteString -> String -> Req' -> IO Request buildRequestFromReq method url req = do r <- setQueryString (foldMap (\(s, s') -> [(BS8.pack s, Just (BS8.pack s'))]) req.queryParams) . (\r -> r {requestBody = RequestBodyLBS $ Aeson.encode req.jsonBody})- . (\r -> r {method = BS8.pack method})+ . (\r -> r {method = method}) <$> parseRequest url let err = hPutStrLn stderr when req.inspectRequest do@@ -152,7 +153,7 @@ exitFailure pure r -httpWithManager :: MonadIO m => String -> String -> Req -> m LazyByteString+httpWithManager :: MonadIO m => StrictByteString -> String -> Req -> m LazyByteString httpWithManager method url req = liftIO do r <- buildRequestFromReq method url $ req.appReq defaultReq' manager <- newManager if r.secure then tlsManagerSettings else defaultManagerSettings