Довёл fix20: firewall-mode, staged state, diagnostics, readiness и build-gate
This commit is contained in:
@@ -2,12 +2,40 @@ package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/dao"
|
||||
"hy2xs-admin/frontend"
|
||||
"hy2xs-admin/middleware"
|
||||
"hy2xs-admin/model/constant"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Router(router *gin.Engine, huiWebContext *string) {
|
||||
router.GET("/healthz", func(c *gin.Context) {
|
||||
sqliteReady := dao.IsSqliteReady()
|
||||
configReadable := false
|
||||
if stat, err := os.Stat(constant.Hysteria2ConfigPath); err == nil {
|
||||
configReadable = !stat.IsDir()
|
||||
}
|
||||
|
||||
if !sqliteReady || !configReadable {
|
||||
c.JSON(503, gin.H{
|
||||
"ok": false,
|
||||
"service": "hy2xs-admin",
|
||||
"sqlite_ready": sqliteReady,
|
||||
"config_readable": configReadable,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"ok": true,
|
||||
"service": "hy2xs-admin",
|
||||
"sqlite_ready": true,
|
||||
"config_readable": true,
|
||||
})
|
||||
})
|
||||
|
||||
relativePath := "/"
|
||||
if huiWebContext != nil && strings.HasPrefix(*huiWebContext, "/") {
|
||||
relativePath = *huiWebContext
|
||||
|
||||
Reference in New Issue
Block a user