packages feed

wai-extra 2.1.1.2 → 2.1.1.3

raw patch · 3 files changed

+20/−12 lines, 3 filesnew-uploaderPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Network/Wai/Middleware/RequestLogger.hs view
@@ -29,6 +29,7 @@ import Network.HTTP.Types as H import Data.Maybe (fromMaybe) import Data.Monoid (mconcat)+import Data.Time (getCurrentTime, diffUTCTime)  import Network.Wai.Parse (sinkRequestBody, lbsBackEnd, fileName, Param, File, getRequestBodyType) import qualified Data.ByteString.Lazy as LBS@@ -155,13 +156,11 @@ -- -- Example ouput: ----- > GET search--- > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8+-- > GET search :: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 -- > -- > Status: 200 OK. search -- >--- > GET static/css/normalize.css--- > Accept: text/css,*/*;q=0.1+-- > GET static/css/normalize.css :: text/css,*/*;q=0.1 -- > GET [("LXwioiBG","")] -- > -- > Status: 304 Not Modified. static/css/normalize.css@@ -237,7 +236,9 @@         , "\n"         ] +    t0 <- getCurrentTime     rsp <- app req'+    t1 <- getCurrentTime      -- log the status of the response     -- this is color coordinated with the request logging@@ -246,6 +247,8 @@         addColor "Status: " ++ statusBS rsp ++         [ " "         , msgBS rsp+        , ". "+        , pack $ show $ diffUTCTime t1 t0         , ". "         , rawPathInfo req -- if you need help matching the 2 logging statements         , "\n"
test/WaiExtraTest.hs view
@@ -3,7 +3,7 @@  import Test.Hspec import Test.HUnit hiding (Test)-import Data.Monoid (mappend, mempty)+import Data.Monoid (mappend, mempty, (<>))  import Network.Wai import Network.Wai.Test@@ -545,21 +545,26 @@   where     params = [("foo", "bar"), ("baz", "bin")]     -- FIXME change back once we include post parameter output in logging postOutput = T.pack $ "POST \nAccept: \nPOST " ++ (show params)-    postOutput = T.pack $ "POST / :: \nStatus: 200 OK. /\n"-    getOutput params' = T.pack $ "GET /location :: \nGET " ++ show params' ++ "\nStatus: 200 OK. /location\n"+    -- the time cannot be known, so match around it+    postOutput = ("POST / :: \nStatus: 200 OK. 0", "s. /\n")+    getOutput params' = ("GET /location :: \nGET " <> T.pack (show params') <> "\nStatus: 200 OK. 0", "s. /location\n") -    debugApp output' req = do+    debugApp (beginning, ending) req = do         iactual <- liftIO $ I.newIORef mempty         middleware <- liftIO $ mkRequestLogger def             { destination = Callback $ \strs -> I.modifyIORef iactual $ (`mappend` strs)             , outputFormat = Detailed False             }         res <- middleware (\_req -> return $ responseLBS status200 [ ] "") req-        actual <- liftIO $ I.readIORef iactual-        liftIO $ assertEqual "debug" output $ logToBs actual+        actual <- logToBs <$> liftIO (I.readIORef iactual)+        liftIO $ do+          actual `shouldSatisfy` S.isPrefixOf begin+          actual `shouldSatisfy` S.isSuffixOf end+         return res       where-        output = TE.encodeUtf8 $ T.toStrict output'+        begin = TE.encodeUtf8 $ T.toStrict beginning+        end   = TE.encodeUtf8 $ T.toStrict ending          logToBs = fromLogStr 
wai-extra.cabal view
@@ -1,5 +1,5 @@ Name:                wai-extra-Version:             2.1.1.2+Version:             2.1.1.3 Synopsis:            Provides some basic WAI handlers and middleware. Description:         The goal here is to provide common features without many dependencies. License:             MIT