package handler import ( "net/http" "time" "api-server/internal/config" "github.com/gin-gonic/gin" ) // Handler 基础处理器 type Handler struct { Cfg *config.Config } // New 创建处理器 func New(cfg *config.Config) *Handler { return &Handler{Cfg: cfg} } // Health 健康检查 // @Summary 健康检查 // @Description 返回服务运行状态 // @Tags system // @Produce json // @Success 200 {object} map[string]interface{} // @Router /health [get] func (h *Handler) Health(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "status": "ok", "time": time.Now().UTC().Format(time.RFC3339), }) } // Ping 连通性测试 // @Summary 连通性测试 // @Description 简单的 ping/pong 连通性测试 // @Tags system // @Produce plain // @Success 200 {string} string "pong" // @Router /ping [get] func (h *Handler) Ping(c *gin.Context) { c.String(http.StatusOK, "pong") }