Hi,
I was trying to use chi.Walk to get a report of all routes and the middlewares used by every route. I noticed that some of the middlewares were missing from some of the nested routes when using groups.
Example routes:
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Get("/A", func(w http.ResponseWriter, r *http.Request) {})
r.Group(func(r chi.Router) {
r.Use(middleware.Timeout(2500 * time.Millisecond))
r.Get("/B", func(w http.ResponseWriter, r *http.Request) {})
r.Route("/C", func(r chi.Router) {
// Walk on the below route does not show the Timeout middleware
r.Get("/D", func(w http.ResponseWriter, r *http.Request) {})
})
})
In the example above, I expected the C/D route to have both RequestId and Timeout middlewares. but chi.Walk only shows RequestID.
It's possible I'm missing something here and this is behaving as expected.
Go playground link: https://go.dev/play/p/HKh7cA35Bgx
Hi,
I was trying to use chi.Walk to get a report of all routes and the middlewares used by every route. I noticed that some of the middlewares were missing from some of the nested routes when using groups.
Example routes:
In the example above, I expected the
C/Droute to have both RequestId and Timeout middlewares. but chi.Walk only shows RequestID.It's possible I'm missing something here and this is behaving as expected.
Go playground link: https://go.dev/play/p/HKh7cA35Bgx