onRequest
Protected hook method called on every inbound SWML request, before the document
is returned to SignalWire. Override this in a subclass to inspect the request
and return a customized SwmlBuilder for this request.
Returning null delegates to the next handler in the chain (any callback
registered via setOnRequestCallback(), or the
static builder). The default implementation returns null.
The TypeScript signature differs from the Python SDK’s on_request(request_data, callback_path) in two ways:
- TS receives query params, body params, and headers as separate arguments
instead of merged
request_data. - TS returns a full
SwmlBuilderinstance (ornull) rather than a dictionary of modifications to merge. This means a TS override replaces the document entirely rather than patching it.
Parameters
queryParams
URL query parameters from the request.
bodyParams
Parsed POST body. Empty object for GET requests. Typically contains call
metadata from SignalWire (e.g., call.to, call.from, call.headers).
headers
HTTP request headers.
callbackPath
The routing callback path that matched this request, if any. Set when the
request arrived through a path registered via
registerRoutingCallback(); undefined for
requests to the main route.
Returns
SwmlBuilder | null — a SwmlBuilder whose document is
served for this request, or null to delegate to the next handler.