Migrate remaining 7 ref endpoints to SX, add :returns type annotations
Add 14 new IO primitives to boundary.sx: web interop (request-form, request-json, request-header, request-content-type, request-args-all, request-form-all, request-headers-all, request-file-name), response manipulation (set-response-header, set-response-status), ephemeral state (state-get, state-set!), and timing (now, sleep). All 19 reference handlers now have :returns type annotations using types.sx vocabulary. Response meta (headers/status) flows through context vars, applied by register_route_handlers after execution. Only SSE endpoint remains in Python (async generator paradigm). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -239,10 +239,19 @@ def register_route_handlers(app_or_bp: Any, service_name: str) -> int:
|
||||
|
||||
async def _route_view(_h=_hdef, **path_kwargs):
|
||||
from shared.sx.helpers import sx_response
|
||||
from shared.sx.primitives_io import reset_response_meta, get_response_meta
|
||||
reset_response_meta()
|
||||
args = dict(request.args)
|
||||
args.update(path_kwargs)
|
||||
result = await execute_handler(_h, service_name, args=args)
|
||||
return sx_response(result)
|
||||
resp = sx_response(result)
|
||||
meta = get_response_meta()
|
||||
if meta:
|
||||
if meta.get("status"):
|
||||
resp.status_code = meta["status"]
|
||||
for k, v in meta.get("headers", {}).items():
|
||||
resp.headers[k] = v
|
||||
return resp
|
||||
|
||||
endpoint = f"sx_route_{name}"
|
||||
view_fn = _route_view
|
||||
|
||||
Reference in New Issue
Block a user