about summary refs log tree commit diff stats
path: root/internal
diff options
context:
space:
mode:
authorAlan Pearce2024-05-22 18:58:50 +0200
committerAlan Pearce2024-05-22 18:58:50 +0200
commitc8c7dd2a02eb145632b04d2710d297bd6af63a94 (patch)
treebac6117d7df92c4eacf776ca8f8c142c609fb2c9 /internal
parentea098ab11740fe4783694ff0122738b30e0c342f (diff)
downloadwebsite-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')
-rw-r--r--internal/server/logging.go9
-rw-r--r--internal/server/server.go4
2 files changed, 2 insertions, 11 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
diff --git a/internal/server/server.go b/internal/server/server.go
index 8838dbd..1dbd147 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -107,9 +107,7 @@ func New(runtimeConfig *Config) (*Server, error) {
 			ReadHeaderTimeout: 1 * time.Minute,
 			Handler: sentryHandler.Handle(
 				serverHeaderHandler(
-					wrapHandlerWithLogging(top, wrappedHandlerOptions{
-						defaultHostname: runtimeConfig.BaseURL.Hostname(),
-					}),
+					wrapHandlerWithLogging(top),
 				),
 			),
 		},