Files
mtusi2026lab3/internal/controller/http/fiber/health.go
T

29 lines
737 B
Go

package fiber
import (
"github.com/gofiber/fiber/v2"
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab3/internal/service"
)
// handleLive reports that the server process is running.
func (ctrl *Controller) handleLive(ctx *fiber.Ctx) error {
return ctx.JSON(fiber.Map{"status": "ok"})
}
// handleReady reports readiness unless shutdown has started.
func (ctrl *Controller) handleReady(ctx *fiber.Ctx) error {
if ctrl.stopping.Load() {
return errBusy
}
if err := ctrl.readiness.Ping(ctx.UserContext()); err != nil {
return errBusy
}
return ctrl.handleLive(ctx)
}
// handleNotFound returns the application error for an unmatched route.
func (ctrl *Controller) handleNotFound(_ *fiber.Ctx) error {
return service.ErrNotFound
}