From 177556399dde3ceee90a33abf82c3ad3ca475997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Wed, 24 Jan 2024 23:43:27 -0800 Subject: [PATCH] more middleware --- cmd/web/middleware.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/web/middleware.go b/cmd/web/middleware.go index 1d122e5..6049553 100644 --- a/cmd/web/middleware.go +++ b/cmd/web/middleware.go @@ -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())