diff options
author | Alan Pearce | 2024-05-22 18:58:50 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-22 18:58:50 +0200 |
commit | c8c7dd2a02eb145632b04d2710d297bd6af63a94 (patch) | |
tree | bac6117d7df92c4eacf776ca8f8c142c609fb2c9 /internal/server/logging.go | |
parent | ea098ab11740fe4783694ff0122738b30e0c342f (diff) | |
download | website-c8c7dd2a02eb145632b04d2710d297bd6af63a94.tar.lz website-c8c7dd2a02eb145632b04d2710d297bd6af63a94.tar.zst website-c8c7dd2a02eb145632b04d2710d297bd6af63a94.zip |
refactor: simplify logging of Host header
since net/http doesn't accept requests without a Host header, there's no need for a fallback
Diffstat (limited to 'internal/server/logging.go')
-rw-r--r-- | internal/server/logging.go | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/internal/server/logging.go b/internal/server/logging.go index afcce6d..d70d927 100644 --- a/internal/server/logging.go +++ b/internal/server/logging.go @@ -22,20 +22,13 @@ func NewLoggingResponseWriter(w http.ResponseWriter) *LoggingResponseWriter { return &LoggingResponseWriter{w, http.StatusOK} } -type wrappedHandlerOptions struct { - defaultHostname string -} - -func wrapHandlerWithLogging(wrappedHandler http.Handler, opts wrappedHandlerOptions) http.Handler { +func wrapHandlerWithLogging(wrappedHandler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { scheme := r.Header.Get("X-Forwarded-Proto") if scheme == "" { scheme = "http" } host := r.Host - if host == "" { - host = opts.defaultHostname - } lw := NewLoggingResponseWriter(w) wrappedHandler.ServeHTTP(lw, r) statusCode := lw.statusCode |