- Serverless Programming Cookbook
- Heartin Kanikathottu
- 167字
- 2025-04-04 15:02:17
Passthrough behavior
In the put-integration response, you saw that the passthroughBehavior had the value WHEN_NO_MATCH, which means that, if we do not define a template for the request content type, API Gateway will passthrough the request body to the Lambda.
We can override the passthrough behavior with the passthrough-behavior parameter in the CLI, or with the PassthroughBehavior property within the CloudFormation template. The valid values for this parameter are as follows:
- WHEN_NO_MATCH: This option allows the pass through of the request body for unmapped content types to the backend.
- WHEN_NO_TEMPLATES: This option allows pass through only if the templates are not defined for any content type. If a template is defined for at least one content type, the others will be rejected with a 415 HTTP response status code. The HTTP 415 response status code stands for Unsupported Media Type. This is the recommended option.
- NEVER: This option rejects all unmapped content types with an HTTP 415 response code.