All checks were successful
continuous-integration/drone/push Build is passing
25 lines
671 B
Go
25 lines
671 B
Go
package handler
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
const legacyAPISetting = "settings.enable_legacy_api"
|
|
|
|
func (h *Handler) legacyAPIEnabled() bool {
|
|
if h == nil || h.Settings == nil || h.Settings.Values == nil {
|
|
return false
|
|
}
|
|
return h.Settings.Values.Settings.EnableLegacyAPI
|
|
}
|
|
|
|
func (h *Handler) denyLegacyAPI(w http.ResponseWriter, endpoint string) bool {
|
|
if h.legacyAPIEnabled() {
|
|
return false
|
|
}
|
|
h.Logger.Warn("legacy endpoint request blocked", "endpoint", endpoint, "setting", legacyAPISetting)
|
|
writeJSONError(w, http.StatusGone, fmt.Sprintf("%s is deprecated and disabled; set %s=true to temporarily re-enable", endpoint, legacyAPISetting))
|
|
return true
|
|
}
|