[ci skip] more codex 5.3 improvements
This commit is contained in:
23
server/handler/legacy_gate.go
Normal file
23
server/handler/legacy_gate.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const legacyAPIEnvVar = "VCTP_ENABLE_LEGACY_API"
|
||||
|
||||
func legacyAPIEnabled() bool {
|
||||
return strings.TrimSpace(os.Getenv(legacyAPIEnvVar)) == "1"
|
||||
}
|
||||
|
||||
func (h *Handler) denyLegacyAPI(w http.ResponseWriter, endpoint string) bool {
|
||||
if 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))
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user