1Panel/backend/middleware/helper.go
2024-11-13 06:44:00 +00:00

33 lines
612 B
Go

package middleware
import (
"net/http"
"github.com/1Panel-dev/1Panel/backend/app/repo"
)
func LoadErrCode() int {
settingRepo := repo.NewISettingRepo()
codeVal, err := settingRepo.Get(settingRepo.WithByKey("NoAuthSetting"))
if err != nil {
return 500
}
switch codeVal.Value {
case "400":
return http.StatusBadRequest
case "401":
return http.StatusUnauthorized
case "403":
return http.StatusForbidden
case "404":
return http.StatusNotFound
case "408":
return http.StatusRequestTimeout
case "416":
return http.StatusRequestedRangeNotSatisfiable
default:
return http.StatusOK
}
}