Files
vctp2/server/handler/legacy_gate.go
Nathan Coad c66679a71f
All checks were successful
continuous-integration/drone/push Build is passing
more index cleanups to optimise space
2026-02-08 15:40:42 +11:00

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
}