Optional
bodyA string or buffer, which replaces the response body if set. This will be automatically encoded to match the Content-Encoding defined in your response headers.
If this is set, the Content-Length header will be automatically updated
accordingly to match, unless you also provide a headers
value that
includes a Content-Length header, in which case that will take used
as-is.
Defaults to empty.
You should only return one body field: either body
, rawBody
or
json
.
Optional
headersThe replacement HTTP headers, as an object of string keys and either single string or array of string values.
Defaults to a minimum set of standard required headers if not set.
Optional
jsonA JSON value, which will be stringified and send as a JSON-encoded request body. This will be automatically content-encoded to match the Content-Encoding defined in your response headers.
If this is set, the Content-Length header will be automatically updated
accordingly to match, unless you also provide a headers
value that
includes a Content-Length header, in which case that will take used
as-is.
You should only return one body field: either body
, rawBody
or
json
.
Optional
rawA buffer, which replaces the response body if set, which is sent exactly as is, and is not automatically encoded.
If this is set, the Content-Length header will be automatically updated
accordingly to match, unless you also provide a headers
value that
includes a Content-Length header, in which case that will take used
as-is.
You should only return one body field: either body
, rawBody
or
json
.
Optional
statusSupported only for backward compatibility.
Optional
statusThe response status code as a number.
Defaults to 200 if not set.
Optional
statusThe response status message, as a string. This is ignored for HTTP/2 responses.
Defaults to the default status message for the status code if not set.
Optional
trailersThe replacement HTTP trailers, as an object of string keys and either single string or array of string values. Note that there are not all header fields are valid as trailers, and there are other requirements such as chunked encoding that must be met for trailers to be sent successfully.
Can be returned from callbacks to define parts of a response, or override parts when given an existing repsonse.
All fields are optional, and omitted values will default to the original response value or a default value.