diff --git a/README.md b/README.md index 8d3875a..88deb1d 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,19 @@ chi-prometheus is uses as a middleware. It also supports both a default registry ```go r := chi.NewRouter() m := chiprometheus.New("test") + # use DefaultRegisterer m.MustRegisterDefault() r.Use(m.Handler) r.Handle("/metrics", promhttp.Handler()) - r.Get(`/healthz`, [YOUR HandlerFunc]) + r.Get("/healthz", [YOUR HandlerFunc]) ``` ### Custom registry ```go r := chi.NewRouter() + # use your registry that works well with promauto + # see also https://github.com/prometheus/client_golang/issues/716#issuecomment-590282553 reg := prometheus.NewRegistry() if err := reg.Register(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})); err != nil { t.Error(err) @@ -61,7 +64,7 @@ chi-prometheus is uses as a middleware. It also supports both a default registry ) r.Use(m.Handler) r.Handle("/metrics", promh) - r.Get(`/healthz`, [YOUR HandlerFunc]) + r.Get("/healthz", [YOUR HandlerFunc]) ``` ## Install diff --git a/middleware_test.go b/middleware_test.go index dfd64f3..7ef43a7 100644 --- a/middleware_test.go +++ b/middleware_test.go @@ -71,8 +71,8 @@ func TestMiddleware_Handler(t *testing.T) { }) r.Use(m.Handler) r.Handle("/metrics", promhttp.Handler()) - r.Get(`/healthz`, testHandler) - r.Get(`/users/{firstName}`, testHandler) + r.Get("/healthz", testHandler) + r.Get("/users/{firstName}", testHandler) paths := [][]string{ {"healthz"}, @@ -141,7 +141,7 @@ func TestMiddleware_HandlerWithCustomRegistry(t *testing.T) { r.Use(m.Handler) r.Handle("/metrics", promh) - r.Get(`/healthz`, testHandler) + r.Get("/healthz", testHandler) paths := [][]string{ {"healthz"},