-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathhealth.go
33 lines (28 loc) · 974 Bytes
/
health.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package controller
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/thomaspoignant/go-feature-flag/cmd/relayproxy/service"
)
type health struct {
monitoringService service.Monitoring
}
// NewHealth is a constructor to create a new controller for the health method
func NewHealth(monitoring service.Monitoring) Controller {
return &health{
monitoringService: monitoring,
}
}
// Handler is the entry point for this API
// @Summary Health
// @Tags Monitoring
// @Description Making a **GET** request to the URL path `/health` will tell you if the relay proxy is ready to serve
// @Description traffic.
// @Description
// @Description This is useful especially for loadbalancer to know that they can send traffic to the service.
// @Produce json
// @Success 200 {object} model.HealthResponse
// @Router /health [get]
func (h *health) Handler(c echo.Context) error {
return c.JSON(http.StatusOK, h.monitoringService.Health())
}