mirror of
https://github.com/typeable/wai.git
synced 2024-12-28 16:46:28 +03:00
Supply response size to custom loggers when available.
This commit is contained in:
parent
8f9662b4a1
commit
913d584a7c
@ -118,8 +118,8 @@ apacheMiddleware ala app req sendResponse = app req $ \res -> do
|
||||
customMiddleware :: Callback -> IO ZonedDate -> OutputFormatter -> Middleware
|
||||
customMiddleware cb getdate formatter app req sendResponse = app req $ \res -> do
|
||||
date <- liftIO getdate
|
||||
-- We use Nothing for the response size since we generally don't know it
|
||||
liftIO $ cb $ formatter date req (responseStatus res) Nothing
|
||||
let msize = contentLength (responseHeaders res)
|
||||
liftIO $ cb $ formatter date req (responseStatus res) msize
|
||||
sendResponse res
|
||||
|
||||
customMiddlewareWithDetails :: Callback -> IO ZonedDate -> OutputFormatterWithDetails -> Middleware
|
||||
@ -129,12 +129,12 @@ customMiddlewareWithDetails cb getdate formatter app req sendResponse = do
|
||||
app req' $ \res -> do
|
||||
t1 <- getCurrentTime
|
||||
date <- liftIO getdate
|
||||
-- We use Nothing for the response size since we generally don't know it
|
||||
let msize = contentLength (responseHeaders res)
|
||||
builderIO <- newIORef $ B.byteString ""
|
||||
res' <- recordChunks builderIO res
|
||||
rspRcv <- sendResponse res'
|
||||
_ <- liftIO . cb .
|
||||
formatter date req' (responseStatus res') Nothing (t1 `diffUTCTime` t0) reqBody =<<
|
||||
formatter date req' (responseStatus res') msize (t1 `diffUTCTime` t0) reqBody =<<
|
||||
readIORef builderIO
|
||||
return rspRcv
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
Name: wai-extra
|
||||
Version: 3.0.26
|
||||
Version: 3.0.26.1
|
||||
Synopsis: Provides some basic WAI handlers and middleware.
|
||||
description:
|
||||
Provides basic WAI handler and middleware functionality:
|
||||
|
Loading…
Reference in New Issue
Block a user