more index cleanups to optimise space
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-08 15:40:42 +11:00
parent a993aedf79
commit c66679a71f
13 changed files with 590 additions and 61 deletions

View File

@@ -3,21 +3,22 @@ package handler
import (
"fmt"
"net/http"
"os"
"strings"
)
const legacyAPIEnvVar = "VCTP_ENABLE_LEGACY_API"
const legacyAPISetting = "settings.enable_legacy_api"
func legacyAPIEnabled() bool {
return strings.TrimSpace(os.Getenv(legacyAPIEnvVar)) == "1"
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 legacyAPIEnabled() {
if h.legacyAPIEnabled() {
return false
}
h.Logger.Warn("legacy endpoint request blocked", "endpoint", endpoint, "env_var", legacyAPIEnvVar)
writeJSONError(w, http.StatusGone, fmt.Sprintf("%s is deprecated and disabled; set %s=1 to temporarily re-enable", endpoint, legacyAPIEnvVar))
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
}