feat: 修改 api 为 option 模式设置; 添加 healthz handler

This commit is contained in:
zhaoyupeng
2025-07-11 11:52:53 +08:00
parent 7f49105b23
commit fad0b852cb
2 changed files with 88 additions and 14 deletions

19
handler/healthz.go Normal file
View File

@ -0,0 +1,19 @@
package handler
import (
"gitea.loveuer.com/yizhisec/packages/resp"
"github.com/gin-gonic/gin"
"time"
)
func Healthz(name, version string) gin.HandlerFunc {
start := time.Now()
return func(c *gin.Context) {
resp.R200(c, gin.H{
"name": name,
"version": version,
"start_at": start,
"uptime": time.Since(start).String(),
})
}
}