CasaOS/route/v2/health.go
Tiger Wang 0bb138e39e
add API for checking casaos-* service status (#852)
Signed-off-by: Tiger Wang <tigerwang@outlook.com>
2023-01-30 17:01:47 -05:00

26 lines
597 B
Go

package v2
import (
"net/http"
"github.com/IceWhaleTech/CasaOS/codegen"
"github.com/IceWhaleTech/CasaOS/service"
"github.com/labstack/echo/v4"
)
func (s *CasaOS) GetHealthServices(ctx echo.Context) error {
services, err := service.MyService.Health().Services()
if err != nil {
message := err.Error()
return ctx.JSON(http.StatusInternalServerError, codegen.ResponseInternalServerError{
Message: &message,
})
}
return ctx.JSON(http.StatusOK, codegen.GetHealthServicesOK{
Data: &codegen.HealthServices{
Running: services[true],
NotRunning: services[false],
},
})
}