@Generated(value="jsii-pacmak/1.50.0 (build d1830a4)", date="2022-01-04T15:39:01.803Z") @Stability(value=Experimental) public enum PassthroughBehavior extends Enum<PassthroughBehavior>
Function hello;
LambdaIntegration integration = LambdaIntegration.Builder.create(hello)
.proxy(false)
.requestParameters(Map.of(
// You can define mapping parameters from your method to your integration
// - Destination parameters (the key) are the integration parameters (used in mappings)
// - Source parameters (the value) are the source request parameters or expressions
// @see: https://docs.aws.amazon.com/apigateway/latest/developerguide/request-response-data-mappings.html
"integration.request.querystring.who", "method.request.querystring.who"))
.allowTestInvoke(true)
.requestTemplates(Map.of(
// You can define a mapping that will build a payload for your integration, based
// on the integration parameters that you have specified
// Check: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
"application/json", JSON.stringify(Map.of("action", "sayHello", "pollId", "$util.escapeJavaScript($input.params('who'))"))))
// This parameter defines the behavior of the engine is no suitable response template is found
.passthroughBehavior(PassthroughBehavior.NEVER)
.integrationResponses(List.of(IntegrationResponse.builder()
// Successful response from the Lambda function, no filter defined
// - the selectionPattern filter only tests the error message
// We will set the response status code to 200
.statusCode("200")
.responseTemplates(Map.of(
// This template takes the "message" result from the Lambda function, and embeds it in a JSON response
// Check https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
"application/json", JSON.stringify(Map.of("state", "ok", "greeting", "$util.escapeJavaScript($input.body)"))))
.responseParameters(Map.of(
// We can map response parameters
// - Destination parameters (the key) are the response parameters (used in mappings)
// - Source parameters (the value) are the integration response parameters or expressions
"method.response.header.Content-Type", "'application/json'",
"method.response.header.Access-Control-Allow-Origin", "'*'",
"method.response.header.Access-Control-Allow-Credentials", "'true'"))
.build(), IntegrationResponse.builder()
// For errors, we check if the error message is not empty, get the error data
.selectionPattern("(\n|.)+")
// We will set the response status code to 200
.statusCode("400")
.responseTemplates(Map.of(
"application/json", JSON.stringify(Map.of("state", "error", "message", "$util.escapeJavaScript($input.path('$.errorMessage'))"))))
.responseParameters(Map.of(
"method.response.header.Content-Type", "'application/json'",
"method.response.header.Access-Control-Allow-Origin", "'*'",
"method.response.header.Access-Control-Allow-Credentials", "'true'"))
.build()))
.build();
| Enum Constant and Description |
|---|
NEVER
(experimental) Rejects unmapped content types with an HTTP 415 'Unsupported Media Type' response.
|
WHEN_NO_MATCH
(experimental) Passes the request body for unmapped content types through to the integration back end without transformation.
|
WHEN_NO_TEMPLATES
(experimental) Allows pass-through when the integration has NO content types mapped to templates.
|
| Modifier and Type | Method and Description |
|---|---|
static PassthroughBehavior |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static PassthroughBehavior[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
@Stability(value=Experimental) public static final PassthroughBehavior WHEN_NO_MATCH
@Stability(value=Experimental) public static final PassthroughBehavior NEVER
@Stability(value=Experimental) public static final PassthroughBehavior WHEN_NO_TEMPLATES
However if there is at least one content type defined, unmapped content types will be rejected with the same 415 response.
public static PassthroughBehavior[] values()
for (PassthroughBehavior c : PassthroughBehavior.values()) System.out.println(c);
public static PassthroughBehavior valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullCopyright © 2022. All rights reserved.