Kind: Interface
Source: src/adapter/lambda-edge/handler.ts
Part of: Adapter
CloudFrontResponse represents the response object returned by a Lambda@Edge handler. It carries CloudFront-formatted headers and string status details that CloudFront reads when sending a response.
Properties
| Property | Type |
|---|---|
headers | CloudFrontHeaders |
status | string |
statusDescription | string |
Diagram
mermaidgraph LR Handler[Lambda Edge Handler] --> Response[CloudFrontResponse] Response --> Headers[CloudFrontHeaders] Response --> Status[status] Response --> Description[statusDescription] Response --> CloudFront[CloudFront]
Usage
tsimport type { CloudFrontHeaders, CloudFrontResponse } from './handler';
function createResponse(
headers: CloudFrontHeaders,
status: string,
statusDescription: string,
): CloudFrontResponse {
return {
headers,
status,
statusDescription,
};
}
const response = createResponse(
requestHeaders,
responseStatus,
responseDescription,
);
AI Coding Instructions
- Return
CloudFrontResponsefrom Lambda@Edge handlers when constructing a CloudFront response. - Keep
headersin theCloudFrontHeadersformat expected by CloudFront. - Set both
statusandstatusDescriptionas strings. - Preserve header names and values required by the response path.
How it works
CloudFrontResponse is an exported TypeScript interface for the optional response member of a CloudFront event record’s cf object. src/adapter/lambda-edge/handler.ts:56-60 src/adapter/lambda-edge/handler.ts:69-75
headersis required and maps header names to arrays of{ key, value }entries, allowing multiple values for one header name. src/adapter/lambda-edge/handler.ts:10-17 src/adapter/lambda-edge/handler.ts:56-58statusis required and typed as a string.statusDescriptionis optional and typed as a string. src/adapter/lambda-edge/handler.ts:56-60- It declares no body or body-encoding fields. src/adapter/lambda-edge/handler.ts:56-60
When handle() invokes the Hono application, it places the incoming event’s optional cf.response value in the fetch context as response. src/adapter/lambda-edge/handler.ts:128-141 The adapter does not otherwise read, validate, transform, or return that value in this file; response conversion instead operates on the Response returned by the application and creates a separate internal CloudFrontResult shape. src/adapter/lambda-edge/handler.ts:149-162
Was this page helpful?