internal: fix empty scheme field

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-01-14 23:27:34 +01:00
parent 69d4719687
commit 2deb185550
No known key found for this signature in database
1 changed files with 8 additions and 6 deletions

View File

@ -17,7 +17,6 @@ type responseLogger struct {
w http.ResponseWriter
status int
size int
upstream string
}
// Header returns the ResponseWriter's Header
@ -98,15 +97,18 @@ func (h loggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
responseLogger := &responseLogger{w: w}
h.handler.ServeHTTP(responseLogger, req)
duration := float64(time.Since(t)) / float64(time.Millisecond)
scheme := "http"
if req.TLS != nil {
scheme = "https"
}
h.afterHandler(h.logger.WithFields(log.Fields{
"remote": req.RemoteAddr,
"host": GetHost(req),
"runtime": fmt.Sprintf("%0.3f", duration),
"method": req.Method,
"scheme": req.URL.Scheme,
"scheme": scheme,
"size": responseLogger.Size(),
"status": responseLogger.Status(),
"upstream": responseLogger.upstream,
"user_agent": req.UserAgent(),
}), req).Info(url.RequestURI())
}