packages feed

raven-haskell-scotty 0.1.0.3 → 0.1.1.0

raw patch · 2 files changed

+27/−17 lines, 2 filesdep ~basedep ~scotty

Dependency ranges changed: base, scotty

Files

raven-haskell-scotty.cabal view
@@ -1,5 +1,5 @@ name:                raven-haskell-scotty-version:             0.1.0.3+version:             0.1.1.0 synopsis:            Sentry http interface for Scotty web server. description:         Utilities to log errors in Scotty actions using raven-haskell. homepage:            http://bitbucket.org/dpwiz/raven-haskell@@ -10,16 +10,20 @@ -- copyright:            category:            Web build-type:          Simple-cabal-version:       >=1.8+cabal-version:       >=1.10  library   hs-source-dirs: src/   exposed-modules:     System.Log.Raven.Scotty   build-depends:-    base ==4.*,+    base >= 4.14 && < 5,     raven-haskell,-    scotty, wai, case-insensitive,-    bytestring, text,-    mtl-  extensions: CPP+    bytestring,+    case-insensitive,+    mtl,+    scotty >= 0.12,+    text,+    wai+  default-extensions: CPP+  default-language: Haskell2010
src/System/Log/Raven/Scotty.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}  -- | Utilities to log errors in Scotty actions using raven-haskell.@@ -29,20 +31,23 @@     , scottyHttpInterface     ) where -import Web.Scotty (ActionM, request, reqHeader, params)+import Web.Scotty (ActionM, Param, request, params)  import System.Log.Raven as Raven import System.Log.Raven.Types as Raven-import System.Log.Raven.Transport.HttpConduit (sendRecord) import qualified System.Log.Raven.Interfaces as SI import Network.Wai(Request(..))  import qualified Data.ByteString.Char8 as BS import qualified Data.Text.Lazy as TL+#if MIN_VERSION_scotty(0,21,0)+import qualified Data.Text as T+#endif import qualified Data.CaseInsensitive as CI  import Control.Monad.Trans (liftIO) import Control.Exception (try, throw, SomeException)+import Web.Scotty (header)  -- | A liftIO alternative that logs unhandled exceptions. --   The function itself is verbose in arguments and designed to be curried and reused.@@ -83,17 +88,18 @@              | (h, v) <- requestHeaders r              ] -#if MIN_VERSION_scotty(0,5,0)-    host <- maybe (TL.pack "") id `fmap` reqHeader (TL.pack "Host")-#else-    host <- reqHeader (TL.pack "Host")-#endif+    host <- maybe "" id `fmap` header "Host"      let url = "http://" ++ TL.unpack host ++ BS.unpack (rawPathInfo r)      ps <- params-    let args = SI.QueryArgs [ (TL.unpack k, TL.unpack v)-                            | (k, v) <- ps-                            ]+    let args = SI.QueryArgs $ map fromParam ps      return $ SI.http url method args qs Nothing hs []++fromParam :: Param -> (String, String)+#if MIN_VERSION_scotty(0,21,0)+fromParam (k, v) = (T.unpack k, T.unpack v)+#else+fromParam (k, v) = (TL.unpack k, TL.unpack v)+#endif