more middleware

This commit is contained in:
Lilian Jónsdóttir 2024-01-24 23:43:27 -08:00
parent bedf6cb8e9
commit 177556399d

View file

@ -8,6 +8,10 @@ import (
// Middleware is a slice of Middleware (aka func(n http.Handler) http.Handler {})
var Middleware []func(next http.Handler) http.Handler = []func(next http.Handler) http.Handler{
// chi's recommended list
middleware.RequestID,
middleware.RealIP,
// plus custom request logger
func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
app.Logger.Info("REQUEST", "url", r.URL, "ip", r.RemoteAddr, "useragent", r.UserAgent())