feat(api): add HEAD method for health route (#963)

This commit is contained in:
Julien Neuhart
2024-09-07 17:31:43 +02:00
committed by GitHub
parent a3647fea8a
commit 5cd8c6a5da
2 changed files with 22 additions and 9 deletions

View File

@@ -453,13 +453,22 @@ func (a *Api) Start() error {
)
}
// Let's not forget the health check route...
// Let's not forget the health check routes...
checks := append(a.healthChecks, health.WithTimeout(a.timeout))
checker := health.NewChecker(checks...)
healthCheckHandler := health.NewHandler(checker)
a.srv.GET(
fmt.Sprintf("%s%s", a.rootPath, "health"),
func() echo.HandlerFunc {
checks := append(a.healthChecks, health.WithTimeout(a.timeout))
checker := health.NewChecker(checks...)
return echo.WrapHandler(health.NewHandler(checker))
return echo.WrapHandler(healthCheckHandler)
}(),
hardTimeoutMiddleware(hardTimeout),
)
a.srv.HEAD(
fmt.Sprintf("%s%s", a.rootPath, "health"),
func() echo.HandlerFunc {
return echo.WrapHandler(healthCheckHandler)
}(),
hardTimeoutMiddleware(hardTimeout),
)