Companion
Factories for the common response shapes.
Functions
A response carrying arbitrary body bytes, with the given contentType (default application/octet-stream), status (default 200), and headers (default empty).
A cursor-envelope response for observable list routes (the wire protocol's live-polling shape): {"cursor":..,"status":..,("items":[..],)?(,"state":..)?}.
An enveloped error response. The body is the uniform error envelope JSON {"error":<type>,"message":...,"code":?,"field":?,"hint":?}, where <type> follows from status: bad_request (400), unauthorized (401), forbidden (403), not_found (404), method_not_allowed (405), conflict (409), payload_too_large (413), unprocessable_entity (422), too_many_requests (429), internal_error (500), unavailable (503), timeout (504), and error for any other status. Optional code, field, and hint keys are omitted when null. All string values are escaped via escapeForJson.
A application/json; charset=utf-8 response whose body is built by applying build to a StringBuilder, with the given status (default 200).
A 404 enveloped error response. The body is the uniform error envelope JSON with message (default "Not found").
A stream-envelope response for a route whose list only grows at its end, such as a log: {"cursor":..,"status":..,("items":[..],)?("dropped":n,)?("state":..)?}.
A text response carrying body, with the given status (default 200) and contentType (default text/plain; charset=utf-8).