configure #
Available since 2.11.0
Allows to configure how the API response should be sent to the requesting client.
Arguments #
configure(
options: {
headers?: JSONObject,
status?: number,
format?: 'standard' | 'raw',
result?: any
}): void;The options object may contain the following properties:
| Name | Type | Description (default) |
|---|---|---|
headers | JSONObject( null) | Additional response protocol headers |
status | integer( 200) | KuzzleRequest status code, following the HTTP standard |
format | string( null) | The response format, as a standard Kuzzle response or in a unwrapped raw format instead |
result | any | Available since auto The response result. Set only when the property is present (result: null clears it). Unlike setResult, it does not reset the status: without a status option, a pending 102 becomes 200 and any other status is kept |
Example #
request.response.configure({
headers: {
'Location': 'http://kuzzle.io'
},
status: 302,
format: 'raw',
});
// Set a result without touching the status already set on the request
request.response.configure({ result: { acknowledged: true } });