Add stuff
This commit is contained in:
15
routes/log_middleware.go
Normal file
15
routes/log_middleware.go
Normal file
@ -0,0 +1,15 @@
|
||||
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)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user