internal: fix empty scheme field
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
69d4719687
commit
2deb185550
|
@ -14,10 +14,9 @@ import (
|
||||||
// responseLogger is wrapper of http.ResponseWriter that keeps track of its HTTP status
|
// responseLogger is wrapper of http.ResponseWriter that keeps track of its HTTP status
|
||||||
// code and body size
|
// code and body size
|
||||||
type responseLogger struct {
|
type responseLogger struct {
|
||||||
w http.ResponseWriter
|
w http.ResponseWriter
|
||||||
status int
|
status int
|
||||||
size int
|
size int
|
||||||
upstream string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header returns the ResponseWriter's Header
|
// Header returns the ResponseWriter's Header
|
||||||
|
@ -98,15 +97,18 @@ func (h loggingHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
responseLogger := &responseLogger{w: w}
|
responseLogger := &responseLogger{w: w}
|
||||||
h.handler.ServeHTTP(responseLogger, req)
|
h.handler.ServeHTTP(responseLogger, req)
|
||||||
duration := float64(time.Since(t)) / float64(time.Millisecond)
|
duration := float64(time.Since(t)) / float64(time.Millisecond)
|
||||||
|
scheme := "http"
|
||||||
|
if req.TLS != nil {
|
||||||
|
scheme = "https"
|
||||||
|
}
|
||||||
h.afterHandler(h.logger.WithFields(log.Fields{
|
h.afterHandler(h.logger.WithFields(log.Fields{
|
||||||
"remote": req.RemoteAddr,
|
"remote": req.RemoteAddr,
|
||||||
"host": GetHost(req),
|
"host": GetHost(req),
|
||||||
"runtime": fmt.Sprintf("%0.3f", duration),
|
"runtime": fmt.Sprintf("%0.3f", duration),
|
||||||
"method": req.Method,
|
"method": req.Method,
|
||||||
"scheme": req.URL.Scheme,
|
"scheme": scheme,
|
||||||
"size": responseLogger.Size(),
|
"size": responseLogger.Size(),
|
||||||
"status": responseLogger.Status(),
|
"status": responseLogger.Status(),
|
||||||
"upstream": responseLogger.upstream,
|
|
||||||
"user_agent": req.UserAgent(),
|
"user_agent": req.UserAgent(),
|
||||||
}), req).Info(url.RequestURI())
|
}), req).Info(url.RequestURI())
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue