packages feed

canteven-http 0.1.1.0 → 0.1.1.1

raw patch · 2 files changed

+11/−10 lines, 2 files

Files

canteven-http.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                canteven-http-version:             0.1.1.0+version:             0.1.1.1 synopsis:            Utilities for HTTP programming. -- description:          homepage:            https://github.com/SumAll/canteven-http
src/Canteven/HTTP.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-} {- |   This module provides some utilities that make for better HTTP-based   programs.@@ -19,7 +20,7 @@ import Control.Exception (SomeException) import Control.Monad (void) import Control.Monad.Catch (try, throwM)-import Control.Monad.Logger (runLoggingT, LoggingT, logInfoN)+import Control.Monad.Logger (runLoggingT, LoggingT, logInfo, logError) import Control.Monad.Trans.Class (lift) import Data.ByteString.Lazy (ByteString, fromStrict) import Data.Monoid ((<>))@@ -83,11 +84,11 @@    This is useful because your wai framework won't always do what you   expect when it encounters random exceptions. For instance, an exception-  thrown in IO may cause functionality of higher-level to be bypassed-  unless they know how to catch and re-throw exceptions (making them more-  complicated). This middleware explicitly will not re-throw exceptions,-  unless those exceptions were encountered after the headers have already-  been sent, e.g. when using 'Network.Wai.StreamingBody'.+  thrown in IO may cause functionality of higher-level middlewares to be+  bypassed unless they know how to catch and re-throw exceptions (making+  them more complicated). This middleware explicitly will not re-throw+  exceptions, unless those exceptions were encountered after the headers+  have already been sent, e.g. when using 'Network.Wai.StreamingBody'.      What it will do is generate a unique id for the exception and print   that ID, so you can easily find it in the logs.@@ -125,7 +126,7 @@     logProblem :: SomeException -> LoggingT IO UUID     logProblem err = do       uuid <- getUUID-      logInfoN . pack+      $(logError) . pack         $ "Internal Server Error [" ++ show uuid ++ "]: "         ++ show (err :: SomeException)       return uuid@@ -141,7 +142,7 @@ -} requestLogging :: LoggerTImpl -> Middleware requestLogging logging app req respond = (`runLoggingT` logging) $ do-    logInfoN . pack+    $(logInfo) . pack       $ "Starting request: " ++ reqStr     lift . app req . loggingRespond =<< lift getCurrentTime   where@@ -154,7 +155,7 @@       -}       ack <- lift $ respond response       now <- lift getCurrentTime-      logInfoN . pack+      $(logInfo) . pack         $ reqStr ++ " --> " ++ showStatus (responseStatus response)         ++ " (" ++ show (diffUTCTime now start) ++ ")"       return ack