feat: 修改 api 为 option 模式设置; 添加 healthz handler
This commit is contained in:
19
handler/healthz.go
Normal file
19
handler/healthz.go
Normal 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(),
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user