You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using escapeHttp or terminateConnection to serve a request, the Snap HTTP server will not make any attempt to log the request, or any exception that the handler may throw.
Here is a minimal complete test case for the reported behavior:
$ cat SnapTest.hs
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as BS (hPutStrLn)
import qualified Control.Exception as E
import Snap.Core as Snap
import qualified Snap.Http.Server as Snap
import System.IO (stderr)
config = Snap.setErrorLog (Snap.ConfigIoLog $ BS.hPutStrLn stderr)
$ Snap.setAccessLog (Snap.ConfigIoLog $ BS.hPutStrLn stderr)
$ Snap.defaultConfig
main = Snap.httpServe config $ route
[ ("escape" , Snap.escapeHttp $ \_ _ _ -> E.throw msg)
, ("terminate", Snap.terminateConnection msg)]
msg = E.AssertionFailed "Hello?"
Request issued
$ curl http://0.0.0.0:8000
<!DOCTYPE html>
<html>
<head>
<title>Not found</title>
</head>
<body>
<code>No handler accepted "/"</code>
</body></html>
$ curl http://0.0.0.0:8000/escape
curl: (52) Empty reply from server
$ curl http://0.0.0.0:8000/terminate
curl: (52) Empty reply from server
and the corresponding log
$ runhaskell SnapTest.hs
no port specified, defaulting to port 8000
Listening on http://0.0.0.0:8000
127.0.0.1 - - [07/Dec/2016:23:04:54 +0100] "GET / HTTP/1.1" 404 198 - "curl/7.30.0"
The second and third request have not generated any log entry.
The text was updated successfully, but these errors were encountered:
When using
escapeHttp
orterminateConnection
to serve a request, the Snap HTTP server will not make any attempt to log the request, or any exception that the handler may throw.I would prefer if Snap logs the requested path and any exception that the handler might throw. I found this useful in my Threepenny-GUI project. See also HeinrichApfelmus/threepenny-gui#145 .
Here is a minimal complete test case for the reported behavior:
Request issued
and the corresponding log
The second and third request have not generated any log entry.
The text was updated successfully, but these errors were encountered: