diff --git a/cmd/signaling/main.go b/cmd/signaling/main.go index 0a53a73..d442138 100644 --- a/cmd/signaling/main.go +++ b/cmd/signaling/main.go @@ -57,6 +57,7 @@ func main() { corsHandler := cors.Default() handler := corsHandler.Handler(mux) handler = util.NoStoreMiddleware(handler) + handler = util.NoLogServedMiddleware(handler) handler = logging.Middleware(handler, logger) if metricsURL, ok := os.LookupEnv("METRICS_URL"); ok { diff --git a/internal/util/http.go b/internal/util/http.go index 33d7a08..b7aee5d 100644 --- a/internal/util/http.go +++ b/internal/util/http.go @@ -160,3 +160,13 @@ func NoStoreMiddleware(next http.Handler) http.Handler { next.ServeHTTP(w, r) }) } + +// NoLogServedMiddleware is an HTTP middleware that marks the request to be ignored by the logging middleware. +// This prevents "served" messages from being logged. +func NoLogServedMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + logging.IgnoreRequest(r) + + next.ServeHTTP(w, r) + }) +}