From 68e7ceabc2596d363c126375813e3e4d7c3d99d8 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 26 Sep 2024 09:57:35 -0300 Subject: [PATCH] do not log requests to static content. --- http_middleware.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/http_middleware.go b/http_middleware.go index 5f477d4..e684fc0 100644 --- a/http_middleware.go +++ b/http_middleware.go @@ -1,9 +1,17 @@ package main -import "net/http" +import ( + "net/http" + "strings" +) func loggingMiddleware(next http.HandlerFunc) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if strings.HasPrefix(r.URL.Path, "/static/") || strings.HasPrefix(r.URL.Path, "/favicon") { + next.ServeHTTP(w, r) + return + } + path := r.URL.Path if r.URL.RawQuery != "" { path += "?" + r.URL.RawQuery