mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
34 lines
935 B
Go
34 lines
935 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
|
|
"github.com/acepanel/panel/internal/app"
|
|
)
|
|
|
|
// Status 检查程序状态
|
|
func Status(t *gotext.Locale) func(next http.Handler) http.Handler {
|
|
return func(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
switch app.Status {
|
|
case app.StatusUpgrade:
|
|
Abort(w, http.StatusServiceUnavailable, t.Get("panel is upgrading, please refresh later"))
|
|
return
|
|
case app.StatusMaintain:
|
|
Abort(w, http.StatusServiceUnavailable, t.Get("panel is maintaining, please refresh later"))
|
|
return
|
|
case app.StatusClosed:
|
|
Abort(w, http.StatusServiceUnavailable, t.Get("panel is closed"))
|
|
return
|
|
case app.StatusFailed:
|
|
Abort(w, http.StatusInternalServerError, t.Get("panel run error, please check or contact support"))
|
|
return
|
|
default:
|
|
next.ServeHTTP(w, r)
|
|
}
|
|
})
|
|
}
|
|
}
|