Developer Preview Feature
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
A RouteHandlerViewResponse can be a ViewDefinitionResponse object or a ViewResponse object.
Use this object to customize response input handled by the LWR server.
1interface ViewDefinitionResponse {
2 status?: number;
3 view: RouteHandlerView;
4 viewParams: Record<string, Json>
5 renderOptions?: RenderOptions;
6 cache?: CacheResponse;
7 headers?: Record<string, string>
8}| Property | Type | Required/Optional | Description |
|---|---|---|---|
status | Number | Optional | The HTTP response status code. |
view | RouteHandlerView | Required | A partial route. |
viewParams | Record<string, Json> | Required | The record is passed into the templates as dynamic content. |
renderOptions | RenderOptions | Optional | Configure settings for metadata collection, embedded asset URLs, and caching the page view response. |
cache | CacheResponse | Optional | Page caching settings. |
headers | Record<string, string> | Optional | HTTP headers. |
1interface RenderOptions {
2 skipMetadataCollection?: boolean;
3 freezeAssets?: boolean;
4 skipCaching?: boolean;
5}| Property | Type | Required/Optional | Description |
|---|---|---|---|
skipMetadataCollection | Boolean | Optional | To skip parsing of body for <link> and <img> tags, set to true. The default value is false. |
freezeAssets | Boolean | Optional | To construct immutable URLs for embedded assets, set this value to true. The default value is set to runtimeEnvironment.immutableAssets. |
skipCaching | Boolean | Optional | To not cache the page view response, set this value to true. The default value is false. |
1interface CacheResponse {
2 ttl?: string | number;
3}| Property | Type | Required/Optional | Description |
|---|---|---|---|
ttl | String/Number | Optional | Set the "max-age” for the "Cache-Control" header. |
Use this object to return a completely custom response override.
1interface ViewResponse {
2 status?: number;
3 body: Buffer | string | boolean | Json;
4 cache?: CacheResponse;
5 headers?: Record<string, string>;
6}| Property | Type | Required/Optional | Description |
|---|---|---|---|
status | Number | Optional | The HTTP response status code. |
body | Buffer/string/boolean/json | Required | The response body. |
cache | CacheResponse | Optional | Page caching settings. |
headers | Record<string, string> | Optional | HTTP headers. |
See Also
Developer Preview Feature