Customising Responses
Explore how to customize HTTP responses with AWS Lambda and API Gateway by formatting JSON responses and serving HTML content. Learn about response structure, headers, and best practices for deploying web forms using Lambda functions.
We'll cover the following...
We'll cover the following...
API Gateway expects responses in a specific format from Lambda Proxy integrations. The response needs to be a JSON object containing these fields:
statusCodeshould be a number containing the numeric HTTP response code. The number200means OK.bodyshould be a string representing the response contents.headersis an optional argument and can contain a map of HTTP response headers.
SAM assumes that you’ll use API Gateway to create JSON APIs, so unless the response provides a content type, it assumes that you’ll be sending back a serialised JSON ...