t2/routes/log_middleware.go

16 lines
295 B
Go

package routes
import (
"log/slog"
"net/http"
)
func LogMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
slog.Info("request", "method", r.Method, "path", r.URL.Path, "origin", r.RemoteAddr)
next.ServeHTTP(w, r)
})
}