You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
820 B
29 lines
820 B
package handlers
|
|
|
|
import (
|
|
"github.com/go-openapi/runtime/middleware"
|
|
"github.com/haproxytech/client-native/v6/models"
|
|
"github.com/haproxytech/dataplaneapi/haproxy"
|
|
"github.com/haproxytech/dataplaneapi/operations/health"
|
|
)
|
|
|
|
// GetHaproxyProcessInfoHandlerImpl implementation of the GetHaproxyProcessInfoHandler interface using client-native client
|
|
type GetHealthHandlerImpl struct {
|
|
HAProxy haproxy.IReloadAgent
|
|
}
|
|
|
|
func (h *GetHealthHandlerImpl) Handle(health.GetHealthParams, interface{}) middleware.Responder {
|
|
data := models.Health{}
|
|
status, err := h.HAProxy.Status()
|
|
if err == nil {
|
|
if status {
|
|
data.Haproxy = models.HealthHaproxyUp
|
|
} else {
|
|
data.Haproxy = models.HealthHaproxyDown
|
|
}
|
|
} else {
|
|
data.Haproxy = models.HealthHaproxyUnknown
|
|
}
|
|
|
|
return health.NewGetHealthOK().WithPayload(&data)
|
|
}
|
|
|