formatting and extra test

Can probably slim down the `ExcludePath` tests.
This commit is contained in:
Karl Skewes 2019-06-03 10:04:15 +12:00
parent c4f20fff3d
commit 08021429ea
2 changed files with 2 additions and 0 deletions

View File

@ -24,6 +24,7 @@ func TestLoggingHandler_ServeHTTP(t *testing.T) {
{logger.DefaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/foo/bar\" HTTP/1.1 \"\" 200 4 0.000\n", logger.FormatTimestamp(ts)), "/foo/bar", ""},
{logger.DefaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/foo/bar\" HTTP/1.1 \"\" 200 4 0.000\n", logger.FormatTimestamp(ts)), "/foo/bar", "/ping"},
{logger.DefaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/ping\" HTTP/1.1 \"\" 200 4 0.000\n", logger.FormatTimestamp(ts)), "/ping", ""},
{logger.DefaultRequestLoggingFormat, "", "/ping", "/ping"},
{"{{.RequestMethod}}", "GET\n", "/foo/bar", ""},
{"{{.RequestMethod}}", "GET\n", "/foo/bar", "/ping"},
{"{{.RequestMethod}}", "GET\n", "/ping", ""},

View File

@ -182,6 +182,7 @@ func (l *Logger) PrintReq(username, upstream string, req *http.Request, url url.
if url.Path == l.excludePath {
return
}
duration := float64(time.Now().Sub(ts)) / float64(time.Second)
if username == "" {