1Panel/backend/middleware/loading.go

25 lines
664 B
Go
Raw Normal View History

2023-01-31 15:22:05 +08:00
package middleware
import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/repo"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/gin-gonic/gin"
)
func GlobalLoading() gin.HandlerFunc {
return func(c *gin.Context) {
settingRepo := repo.NewISettingRepo()
2023-02-02 15:01:37 +08:00
status, err := settingRepo.Get(settingRepo.WithByKey("SystemStatus"))
2023-01-31 15:22:05 +08:00
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
2023-02-02 15:01:37 +08:00
if status.Value != "Free" {
helper.ErrorWithDetail(c, constant.CodeGlobalLoading, status.Value, err)
2023-01-31 15:22:05 +08:00
return
}
c.Next()
}
}