Add stuff

This commit is contained in:
Henri Burau
2024-06-06 21:30:29 +02:00
parent 72dce76e2b
commit ddbfc32fb1
13 changed files with 77 additions and 20 deletions

15
routes/log_middleware.go Normal file
View 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)
})
}