A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_apigateway/PassthroughBehavior.html below:

PassthroughBehavior — AWS Cloud Development Kit 1.204.0 documentation

AWS Cloud Development Kit PassthroughBehavior
class aws_cdk.aws_apigateway.PassthroughBehavior(value)

Bases: Enum

ExampleMetadata:

lit=test/authorizers/integ.request-authorizer.lit.ts infused

Example:

from aws_cdk.aws_apigateway import IntegrationResponse, MethodResponse
import path as path
import aws_cdk.aws_lambda as lambda_
from aws_cdk.core import App, Stack
from aws_cdk.aws_apigateway import MockIntegration, PassthroughBehavior, RestApi
from aws_cdk.aws_apigateway import RequestAuthorizer
from aws_cdk.aws_apigateway import 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()
stack = Stack(app, "RequestAuthorizerInteg")

authorizer_fn = lambda_.Function(stack, "MyAuthorizerFunction",
    runtime=lambda_.Runtime.NODEJS_14_X,
    handler="index.handler",
    code=lambda_.AssetCode.from_asset(path.join(__dirname, "integ.request-authorizer.handler"))
)

restapi = RestApi(stack, "MyRestApi")

authorizer = RequestAuthorizer(stack, "MyAuthorizer",
    handler=authorizer_fn,
    identity_sources=[IdentitySource.header("Authorization"), IdentitySource.query_string("allow")]
)

restapi.root.add_method("ANY", MockIntegration(
    integration_responses=[IntegrationResponse(status_code="200")
    ],
    passthrough_behavior=PassthroughBehavior.NEVER,
    request_templates={
        "application/json": "{ "statusCode": 200 }"
    }
),
    method_responses=[MethodResponse(status_code="200")
    ],
    authorizer=authorizer
)

Attributes

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.

However if there is at least one content type defined, unmapped content types will be rejected with the same 415 response.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4