Files
mtusi2026lab5/app/internal/api/http/health.go
T

25 lines
500 B
Go

package http
import (
"net/http"
"github.com/labstack/echo/v4"
)
type healthResponse struct {
Status string `json:"status"`
}
func healthLive(c echo.Context) error {
return c.JSON(http.StatusOK, healthResponse{Status: "ok"})
}
func healthReady(isReady func() bool) echo.HandlerFunc {
return func(c echo.Context) error {
if !isReady() {
return echo.NewHTTPError(http.StatusServiceUnavailable, "Service unavailable")
}
return c.JSON(http.StatusOK, healthResponse{Status: "ok"})
}
}