do not log requests to static content.

This commit is contained in:
fiatjaf
2024-09-26 09:57:35 -03:00
parent ed270747af
commit 68e7ceabc2

View File

@@ -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