mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-02-10 05:28:14 -05:00
24 lines
528 B
Go
24 lines
528 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
h "npm/internal/api/http"
|
|
"npm/internal/config"
|
|
)
|
|
|
|
// EnforceSetup will error if the config setup doesn't match what is required
|
|
func EnforceSetup() func(http.Handler) http.Handler {
|
|
return func(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
if !config.IsSetup {
|
|
h.ResultErrorJSON(w, r, http.StatusForbidden, "Not available during setup phase", nil)
|
|
return
|
|
}
|
|
|
|
// All good
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|
|
}
|