http
http
The http worker exposes registered functions as HTTP endpoints, turning a
function into a route that browsers, webhooks, and external clients can call
without using the iii SDK. A route is an observer of http::on-request: the
args name the route, and the target is the function that answers it:
iii.observe({ function_id: 'http::on-request', args: { method, path } }, target).
Install it with iii call compose::add worker=http.
Every HTTP request is one call of http::on-request. The worker matches the
request's method and path to a route and calls that route's target with the
request: method, path template, headers, query params, extracted :path
params, parsed body, and request/response stream channels. A path without a
route gets 404, and a path whose routes are on other methods gets 405.
Returning a JSON value yields a buffered response; writing to the response
channel yields a chunked streaming response.