packages feed

context-wai-middleware 0.2.0.0 → 0.2.0.1

raw patch · 5 files changed

+27/−25 lines, 5 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Change log +## 0.2.0.1++* Backwards compatibility with GHC 8.4 (@pbrisbin)+ ## 0.2.0.0  * Dependency bump: `context-0.2.0.0`
context-wai-middleware.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           context-wai-middleware-version:        0.2.0.0+version:        0.2.0.1 synopsis:       Add request-specific (or not!) context to your WAI applications description:    Add request-specific (or not!) context to your WAI applications. category:       Web@@ -37,7 +37,7 @@       library   ghc-options: -Wall -fwarn-tabs -Wincomplete-uni-patterns -Wredundant-constraints   build-depends:-      base >=4.12 && <5+      base >=4.11.1.0 && <5     , context >=0.2.0.0 && <0.3     , wai >=3.0.3.0 && <3.3   default-language: Haskell2010
library/Network/Wai/Middleware/Context.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE BlockArguments #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NoImplicitPrelude #-} @@ -32,7 +31,7 @@   -> Wai.Middleware addRequestContext contextStore mkContext app = \request sendResponse -> do   context <- mkContext request-  Context.use contextStore context do+  Context.use contextStore context $ do     app request sendResponse  -- | Register request-specific context into the provided 'Context.Store', for@@ -53,7 +52,7 @@   mkContext request >>= \case     Nothing -> app request sendResponse     Just context ->-      Context.use contextStore context do+      Context.use contextStore context $ do         app request sendResponse  -- | Register arbitrary context into the provided 'Context.Store', for@@ -69,5 +68,5 @@ addContext :: Context.Store ctx -> IO ctx -> Wai.Middleware addContext contextStore mkContext app = \request sendResponse -> do   context <- mkContext-  Context.use contextStore context do+  Context.use contextStore context $ do     app request sendResponse
package.yaml view
@@ -1,5 +1,5 @@ name: context-wai-middleware-version: '0.2.0.0'+version: '0.2.0.1' github: "jship/context/context-wai-middleware" license: MIT license-file: LICENSE.md@@ -25,7 +25,7 @@  library:   dependencies:-  - base >=4.12 && <5+  - base >=4.11.1.0 && <5   - context >=0.2.0.0 && <0.3   - wai >=3.0.3.0 && <3.3   source-dirs: library
test-suite/Test/Network/Wai/Middleware/ContextSpec.hs view
@@ -1,6 +1,5 @@ {-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} -{-# LANGUAGE BlockArguments #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-}@@ -32,8 +31,8 @@  spec :: Spec spec = do-  describe "addRequestContext" do-    it "concurrent test" do+  describe "addRequestContext" $ do+    it "concurrent test" $ do       -- This function creates a value of our context type - 'Int' - by       -- plucking the "number" header off the request. The header must be       -- present.@@ -42,17 +41,17 @@             let headers = Wai.requestHeaders request             let [number] =                   fmap (read . ByteString.Char8.unpack . snd)-                    $ flip filter headers \(headerName, _) ->+                    $ flip filter headers $ \(headerName, _) ->                       "number" == CI.foldedCase headerName             pure number -      Context.withEmptyStore \contextStore -> do+      Context.withEmptyStore $ \contextStore -> do         numberQueue <- TQueue.newTQueueIO         runTest numberQueue contextStore           $ Middleware.addRequestContext contextStore mkContext -  describe "addRequestContextMay" do-    it "concurrent test" do+  describe "addRequestContextMay" $ do+    it "concurrent test" $ do       -- This function creates a value of our context type - 'Int' - by       -- plucking the "number" header off the request, if present.       let mkContext :: Request -> IO (Maybe Int)@@ -61,27 +60,27 @@             let mNumber@Just {} =                   Maybe.listToMaybe                     $ fmap (read . ByteString.Char8.unpack . snd)-                    $ flip filter headers \(headerName, _) ->+                    $ flip filter headers $ \(headerName, _) ->                         "number" == CI.foldedCase headerName             pure mNumber -      Context.withEmptyStore \contextStore -> do+      Context.withEmptyStore $ \contextStore -> do         numberQueue <- TQueue.newTQueueIO         runTest numberQueue contextStore           $ Middleware.addRequestContextMay contextStore mkContext -  describe "addContext" do-    it "concurrent test" do+  describe "addContext" $ do+    it "concurrent test" $ do       counterRef <- IORef.newIORef 0        -- This function creates a value of our context type - 'Int' - by       -- using a sequential counter.       let mkContext :: IO Int           mkContext = do-            IORef.atomicModifyIORef' counterRef \counter ->+            IORef.atomicModifyIORef' counterRef $ \counter ->               (1 + counter, 1 + counter) -      Context.withEmptyStore \contextStore -> do+      Context.withEmptyStore $ \contextStore -> do         numberQueue <- TQueue.newTQueueIO         runTest numberQueue contextStore           $ Middleware.addContext contextStore mkContext@@ -89,7 +88,7 @@ runTest :: TQueue Int -> Context.Store Int -> Middleware -> IO () runTest numberQueue contextStore middleware = do   let app =-        middleware \_request sendResponse -> do+        middleware $ \_request sendResponse -> do           -- Ask for the request handler thread's context, then write it           -- to the number queue, if present.           Context.mineMay contextStore >>= \case@@ -105,14 +104,14 @@                 "Test.Network.Wai.Middleware.ContextSpec"    -- Spin up a test server for the 'app' defined above.-  Warp.testWithApplication (pure app) \port -> do+  Warp.testWithApplication (pure app) $ \port -> do     manager <- HTTP.Client.newManager HTTP.Client.defaultManagerSettings     request <- HTTP.Client.parseRequest $ "http://localhost:" <> show port <> "/abc/def"      -- Spin up 10 threads that each make 3 http requests into the test     -- server.-    Async.forConcurrently_ [0 :: Int .. 9] \i -> do-      Foldable.for_ [1..3] \j -> do+    Async.forConcurrently_ [0 :: Int .. 9] $ \i -> do+      Foldable.for_ [1..3] $ \j -> do         -- Every request gets a "number" header added to it.         let newHeader = ("number", ByteString.Char8.pack $ show $ 3 * i + j)         response <- flip HTTP.Client.httpLbs manager request