forked from mtusi2026/mtusi2026lab6
ЛР 6 — БПИ2302 — Нурлыгаянова — на 3
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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"})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user