Open mo-rieger opened 1 year ago
Hi there,
The Heartbeat middleware is not invoked when attached to a sub router, whereas other middlewares are.
The expected behaviour would be that /connectivity/ping would return 200. Instead, a 404 is returned.
/connectivity/ping
200
404
package main import ( "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" ) func main() { r := chi.NewRouter() r.Use(middleware.RequestID) r.Use(middleware.RealIP) r.Use(middleware.Recoverer) r.Mount("/connectivity", NewSubrouter()) http.ListenAndServe(":3333", r) } func NewSubrouter() chi.Router { r := chi.NewRouter() r.Use(middleware.Logger) r.Use(middleware.Heartbeat("/ping")) r.Get("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(".")) }) return r }
Best, Moritz
I created PR for this issue, please check
Please see https://github.com/go-chi/chi/pull/822#pullrequestreview-2313031493
Hi there,
The Heartbeat middleware is not invoked when attached to a sub router, whereas other middlewares are.
The expected behaviour would be that
/connectivity/ping
would return200
. Instead, a404
is returned.Best, Moritz