Shield external portal jumps (keep EXTERNAL_* for later), serve /nav from static build, and proxy /book + /community to vertical Next apps with Caddy notes. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
703 B
Python
27 lines
703 B
Python
"""Feature flags for the backend — reads content/features.json."""
|
|
|
|
import json
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
FEATURES_PATH = Path(__file__).resolve().parent.parent.parent / "content" / "features.json"
|
|
|
|
|
|
@lru_cache
|
|
def get_features() -> dict:
|
|
if not FEATURES_PATH.exists():
|
|
return {}
|
|
with open(FEATURES_PATH, encoding="utf-8") as f:
|
|
return json.load(f)
|
|
|
|
|
|
def is_enabled(path: str) -> bool:
|
|
"""Check a dot-separated feature path, e.g. 'payment.crypto.enabled'."""
|
|
obj = get_features()
|
|
for key in path.split("."):
|
|
if isinstance(obj, dict):
|
|
obj = obj.get(key)
|
|
else:
|
|
return False
|
|
return bool(obj)
|