1Panel/core/middleware/loading.go

25 lines
655 B
Go
Raw Normal View History

2024-07-19 19:04:11 +08:00
package middleware
import (
"github.com/1Panel-dev/1Panel/core/app/api/v2/helper"
2024-07-19 19:04:11 +08:00
"github.com/1Panel-dev/1Panel/core/app/repo"
"github.com/1Panel-dev/1Panel/core/constant"
"github.com/gin-gonic/gin"
)
func GlobalLoading() gin.HandlerFunc {
return func(c *gin.Context) {
settingRepo := repo.NewISettingRepo()
status, err := settingRepo.Get(settingRepo.WithByKey("SystemStatus"))
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
if status.Value != "Free" {
helper.ErrorWithDetail(c, constant.CodeGlobalLoading, status.Value, err)
return
}
c.Next()
}
}