Extend defhandler with :path/:method/:csrf, migrate 12 ref endpoints to SX
defhandler now supports keyword options for public route registration: (defhandler name :path "/..." :method :post :csrf false (&key) body) Infrastructure: forms.sx parses options, HandlerDef stores path/method/csrf, register_route_handlers() mounts path-based handlers as app routes. New IO primitives (boundary.sx "Web interop" section): now, sleep, request-form, request-json, request-header, request-content-type. First migration: 12 reference API endpoints from Python f-string SX to declarative .sx handlers in sx/sx/handlers/ref-api.sx. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -222,8 +222,14 @@ def make_macro(params, rest_param, body, env, name=None):
|
||||
closure=dict(env), name=name)
|
||||
|
||||
|
||||
def make_handler_def(name, params, body, env):
|
||||
return HandlerDef(name=name, params=list(params), body=body, closure=dict(env))
|
||||
def make_handler_def(name, params, body, env, opts=None):
|
||||
path = opts.get('path') if opts else None
|
||||
method = str(opts.get('method', 'get')) if opts else 'get'
|
||||
csrf = opts.get('csrf', True) if opts else True
|
||||
if isinstance(csrf, str):
|
||||
csrf = csrf.lower() not in ('false', 'nil', 'no')
|
||||
return HandlerDef(name=name, params=list(params), body=body, closure=dict(env),
|
||||
path=path, method=method.lower(), csrf=csrf)
|
||||
|
||||
|
||||
def make_query_def(name, params, doc, body, env):
|
||||
|
||||
Reference in New Issue
Block a user