diff --git a/config/config.go b/config/config.go index 5229b1f4225..8166a05b8e3 100644 --- a/config/config.go +++ b/config/config.go @@ -30,6 +30,7 @@ import ( "github.com/ory/fosite" foauth2 "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/token/hmac" + "github.com/ory/hydra/health" "github.com/ory/hydra/metrics" "github.com/ory/hydra/pkg" "github.com/ory/hydra/warden/group" @@ -155,7 +156,7 @@ func (c *Config) DoesRequestSatisfyTermination(r *http.Request) error { return errors.New("TLS termination is not enabled") } - if r.URL.Path == "/health" { + if r.URL.Path == health.HealthStatusPath { return nil } diff --git a/health/handler.go b/health/handler.go index df96d7514e3..82e0fd760dd 100644 --- a/health/handler.go +++ b/health/handler.go @@ -23,6 +23,11 @@ import ( "github.com/ory/hydra/metrics" ) +const ( + HealthStatusPath = "/health/status" + HealthMetricsPath = "/health/metrics" +) + type Handler struct { Metrics *metrics.MetricsManager H *herodot.JSONWriter @@ -43,8 +48,8 @@ func (h *Handler) PrefixResource(resource string) string { } func (h *Handler) SetRoutes(r *httprouter.Router) { - r.GET("/health/status", h.Health) - r.GET("/health/metrics", h.Statistics) + r.GET(HealthStatusPath, h.Health) + r.GET(HealthMetricsPath, h.Statistics) } // swagger:route GET /health/status health getInstanceStatus