packages feed

helics-wai 0.1.0 → 0.2.0

raw patch · 3 files changed

+24/−12 lines, 3 filesdep −data-default-classdep ~bytestring

Dependencies removed: data-default-class

Dependency ranges changed: bytestring

Files

helics-wai.cabal view
@@ -1,5 +1,5 @@ name:                helics-wai-version:             0.1.0+version:             0.2.0 synopsis:            New Relic® agent SDK wrapper for wai. description:            New Relic® agent SDK wrapper for wai.@@ -22,13 +22,12 @@  library   exposed-modules:     Network.Helics.Wai+                       Network.Helics.Wai.Safe   -- other-extensions:       build-depends:       base               >=4.6  && <4.8-                     , data-default-class >=0.0  && <0.1                      , wai                >=3.0  && <3.1                      , vault              >=0.3  && <0.4                      , helics             >=0.1  && <0.2-                     , bytestring         >=0.10 && <0.11   ghc-options:         -Wall -O2   hs-source-dirs:      src   default-language:    Haskell2010
src/Network/Helics/Wai.hs view
@@ -1,22 +1,19 @@ module Network.Helics.Wai (helics, transactionId) where  import Network.Wai-import Data.Vault.Lazy as V import Network.Helics-import qualified Data.ByteString as S+import qualified Network.Helics.Wai.Safe as Safe+import qualified Data.Vault.Lazy as V import System.IO.Unsafe -tidKey :: Key TransactionId-tidKey = unsafePerformIO newKey+tidKey :: V.Key TransactionId+tidKey = unsafePerformIO V.newKey {-# NOINLINE tidKey #-}  -- | helics middleware. helics :: Middleware-helics app req send =-   withTransaction (rawPathInfo req) def $ \tid -> do-   setRequestUrl (rawPathInfo req) tid-   app req { vault = insert tidKey tid (vault req) } send+helics = Safe.helics tidKey  -- | get TransactionId from request. transactionId :: Request -> TransactionId-transactionId req = maybe (error "helics middleware is not installed.") id $ V.lookup tidKey (vault req)+transactionId = Safe.transactionId tidKey
+ src/Network/Helics/Wai/Safe.hs view
@@ -0,0 +1,16 @@+module Network.Helics.Wai.Safe (helics, transactionId) where++import Network.Wai+import Network.Helics+import Data.Vault.Lazy as V++-- | helics middleware.+helics :: Key TransactionId -> Middleware+helics key app req send =+   withTransaction (rawPathInfo req) def $ \tid -> do+   setRequestUrl (rawPathInfo req) tid+   app req { vault = insert key tid (vault req) } send++-- | get TransactionId from request.+transactionId :: Key TransactionId -> Request -> TransactionId+transactionId key req = maybe (error "helics middleware is not installed.") id $ V.lookup key (vault req)