2026-05-02 13:02:38 +08:00

31 lines
631 B
Go

package health
import (
"time"
"github.com/gin-gonic/gin"
"hyapp-admin-server/internal/repository"
"hyapp-admin-server/internal/response"
)
type Handler struct {
service *HealthService
}
func New(store *repository.Store, redis RedisHealth, jobs JobStatusProvider) *Handler {
return &Handler{service: NewService(store, redis, jobs, 3*time.Second)}
}
func (h *Handler) Health(c *gin.Context) {
response.OK(c, h.service.Health())
}
func (h *Handler) Ready(c *gin.Context) {
status, err := h.service.Ready(c.Request.Context())
if err != nil {
response.ServerError(c, err.Error())
return
}
response.OK(c, status)
}