Files
janus/internal/handler/healthHandler.go
T
2026-07-09 17:04:56 +08:00

27 lines
491 B
Go

package handler
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type HealthHandler struct {
Database *gorm.DB
}
// Check 健康检查服务
func (handler *HealthHandler) Check(context *gin.Context) {
db, err := handler.Database.DB()
if err != nil {
context.JSON(500, gin.H{"error": "database connect error"})
return
}
err = db.Ping()
if err != nil {
context.JSON(500, gin.H{"error": "database ping error"})
return
}
context.JSON(200, gin.H{"status": "healthy"})
}