@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:36.198Z") @Stability(value=Stable) public enum PassthroughBehavior extends Enum<PassthroughBehavior>
import path.*;
import software.amazon.awscdk.services.lambda.*;
import software.amazon.awscdk.App;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.services.apigateway.MockIntegration;
import software.amazon.awscdk.services.apigateway.PassthroughBehavior;
import software.amazon.awscdk.services.apigateway.RestApi;
import software.amazon.awscdk.services.apigateway.RequestAuthorizer;
import software.amazon.awscdk.services.apigateway.IdentitySource;
// Against the RestApi endpoint from the stack output, run
// `curl -s -o /dev/null -w "%{http_code}" <url>` should return 401
// `curl -s -o /dev/null -w "%{http_code}" -H 'Authorization: deny' <url>?allow=yes` should return 403
// `curl -s -o /dev/null -w "%{http_code}" -H 'Authorization: allow' <url>?allow=yes` should return 200
App app = new App();
Stack stack = new Stack(app, "RequestAuthorizerInteg");
Function authorizerFn = Function.Builder.create(stack, "MyAuthorizerFunction")
.runtime(Runtime.NODEJS_14_X)
.handler("index.handler")
.code(AssetCode.fromAsset(join(__dirname, "integ.request-authorizer.handler")))
.build();
RestApi restapi = RestApi.Builder.create(stack, "MyRestApi").cloudWatchRole(true).build();
RequestAuthorizer authorizer = RequestAuthorizer.Builder.create(stack, "MyAuthorizer")
.handler(authorizerFn)
.identitySources(List.of(IdentitySource.header("Authorization"), IdentitySource.queryString("allow")))
.build();
restapi.root.addMethod("ANY", MockIntegration.Builder.create()
.integrationResponses(List.of(IntegrationResponse.builder().statusCode("200").build()))
.passthroughBehavior(PassthroughBehavior.NEVER)
.requestTemplates(Map.of(
"application/json", "{ \"statusCode\": 200 }"))
.build(), MethodOptions.builder()
.methodResponses(List.of(MethodResponse.builder().statusCode("200").build()))
.authorizer(authorizer)
.build());
| Enum Constant and Description |
|---|
NEVER
Rejects unmapped content types with an HTTP 415 'Unsupported Media Type' response.
|
WHEN_NO_MATCH
Passes the request body for unmapped content types through to the integration back end without transformation.
|
WHEN_NO_TEMPLATES
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=Stable) public static final PassthroughBehavior WHEN_NO_MATCH
@Stability(value=Stable) public static final PassthroughBehavior NEVER
@Stability(value=Stable) 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.