Convert all API endpoint URLs to SX expression format
Every URL at sx-web.org now uses bracketed SX expressions — pages AND API endpoints. defhandler :path values, sx-get/sx-post/sx-delete attrs, code examples, and Python route decorators all converted. - Add SxAtomConverter to handlers.py for parameter matching inside expression URLs (e.g. /(api.(item.<sx:item_id>))) - Convert ~50 defhandler :path values in ref-api.sx and examples.sx - Convert ~90 sx-get/sx-post/sx-delete URLs in reference.sx, examples.sx - Convert ~30 code example URLs in examples-content.sx - Convert ~30 API URLs in pages.py (Python string code examples) - Convert ~70 page navigation URLs in pages.py - Convert 7 Python route decorators in routes.py - Convert ~10 reactive API URLs in marshes.sx - Add API redirect patterns to sx_router.py (301 for old paths) - Remove /api/ skip in app.py redirects (old API paths now redirect) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,11 +24,25 @@ import logging
|
||||
import os
|
||||
from typing import Any, Callable, Awaitable
|
||||
|
||||
from werkzeug.routing import BaseConverter
|
||||
|
||||
from .types import HandlerDef
|
||||
|
||||
logger = logging.getLogger("sx.handlers")
|
||||
|
||||
|
||||
class SxAtomConverter(BaseConverter):
|
||||
"""URL converter for SX atoms inside expression URLs.
|
||||
|
||||
Matches a single atom — stops at dots, parens, slashes, and query chars.
|
||||
Use as ``<sx:param>`` in route patterns like::
|
||||
|
||||
/(geography.(hypermedia.(reference.(api.(item.<sx:item_id>)))))
|
||||
"""
|
||||
|
||||
regex = r"[^./)(?&= ]+"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Registry — service → handler-name → HandlerDef
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -229,6 +243,10 @@ def register_route_handlers(app_or_bp: Any, service_name: str) -> int:
|
||||
from quart import Response, request
|
||||
from shared.browser.app.csrf import csrf_exempt
|
||||
|
||||
# Register SX atom converter for expression URL parameters
|
||||
if hasattr(app_or_bp, 'url_map'):
|
||||
app_or_bp.url_map.converters.setdefault('sx', SxAtomConverter)
|
||||
|
||||
handlers = get_all_handlers(service_name)
|
||||
count = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user