diff options
Diffstat (limited to 'internal/server')
-rw-r--r-- | internal/server/logging.go | 5 | ||||
-rw-r--r-- | internal/server/mux.go | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/internal/server/logging.go b/internal/server/logging.go index 6e2f7c8..5930b9d 100644 --- a/internal/server/logging.go +++ b/internal/server/logging.go @@ -42,9 +42,14 @@ func NewLoggingResponseWriter(w http.ResponseWriter) *LoggingResponseWriter { type wrappedHandlerOptions struct { defaultHostname string logger *log.Logger + enabled bool } func wrapHandlerWithLogging(wrappedHandler http.Handler, opts wrappedHandlerOptions) http.Handler { + if !opts.enabled { + return wrappedHandler + } + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { scheme := r.Header.Get("X-Forwarded-Proto") if scheme == "" { diff --git a/internal/server/mux.go b/internal/server/mux.go index 0403470..9dbcc86 100644 --- a/internal/server/mux.go +++ b/internal/server/mux.go @@ -389,6 +389,7 @@ func NewMux( wrapHandlerWithLogging(mux, wrappedHandlerOptions{ defaultHostname: cfg.Web.BaseURL.Hostname(), logger: log, + enabled: cfg.Web.LogRequests, }), cfg, ), |