@@ -25,24 +25,26 @@ debug = debugDest $ hPutStrLn stderr . T.unpack
25debugDest :: (T.Text -> IO ()) -> Middleware
25debugDest :: (T.Text -> IO ()) -> Middleware
26debugDest cb app req = do
26debugDest cb app req = do
27 body <- consume
27 body <- consume
28− params <- if any (requestMethod req ==) ["GET", "HEAD"]
28+ postParams <- if any (requestMethod req ==) ["GET", "HEAD"]
29− then return $ map emptyGetParam $ queryString req
29+ then return []
30 else do postParams <- liftIO $ allPostParams req body
30 else do postParams <- liftIO $ allPostParams req body
31 return $ collectPostParams postParams
31 return $ collectPostParams postParams
32− let paramS = if null params then "" else "\n" ++ (show params)
32+ let getParams = map emptyGetParam $ queryString req
34 liftIO $ cb $ T.pack $ concat
34 liftIO $ cb $ T.pack $ concat
35 [ unpack $ requestMethod req
35 [ unpack $ requestMethod req
37 , unpack $ rawPathInfo req
37 , unpack $ rawPathInfo req
38− , unpack $ rawQueryString req
40 , (++) "Accept: " $ maybe "" unpack $ lookup "Accept" $ requestHeaders req
39 , (++) "Accept: " $ maybe "" unpack $ lookup "Accept" $ requestHeaders req
41− , paramS
40+ , paramsToStr "GET " getParams
41+ , paramsToStr "POST " postParams
43 -- we just consumed the body- fill the enumerator back up so it is available again
43 -- we just consumed the body- fill the enumerator back up so it is available again
44 liftIO $ run_ $ enumList 1 body $$ app req
44 liftIO $ run_ $ enumList 1 body $$ app req
46+ paramsToStr prefix params = if null params then "" else "\n" ++ prefix ++ (show params)
46 allPostParams req body = run_ $ enumList 1 body $$ parseRequestBody lbsSink req
48 allPostParams req body = run_ $ enumList 1 body $$ parseRequestBody lbsSink req
48 emptyGetParam :: (S.ByteString, Maybe S.ByteString) -> (S.ByteString, S.ByteString)
50 emptyGetParam :: (S.ByteString, Maybe S.ByteString) -> (S.ByteString, S.ByteString)