Files
jiang13-bbs/backend/handler/health.go

26 lines
551 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package handler
import (
"net/http"
"github.com/freefire/jiang13-bbs/model"
"github.com/freefire/jiang13-bbs/version"
"github.com/gin-gonic/gin"
)
// Health 健康检查(官方运行时 Docker HEALTHCHECK 与反代 /health)
func (h *Handlers) Health(c *gin.Context) {
if err := model.PingDB(); err != nil {
c.JSON(http.StatusServiceUnavailable, gin.H{
"status": "error",
"version": version.Version,
})
return
}
c.JSON(http.StatusOK, gin.H{
"status": "ok",
"version": version.Version,
"commit": version.Commit,
})
}