Show / Hide Table of Contents

Class PassthroughBehavior

Inheritance
System.Object
PassthroughBehavior
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public sealed class PassthroughBehavior : Enum
Syntax (vb)
Public NotInheritable Class PassthroughBehavior
    Inherits

     Enum
Remarks

ExampleMetadata: lit=aws-apigateway/test/authorizers/integ.request-authorizer.lit.ts infused

Examples
using Path;
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK;
using Amazon.CDK.AWS.APIGateway;

// 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

var app = new App();
var stack = new Stack(app, "RequestAuthorizerInteg");

var authorizerFn = new Function(stack, "MyAuthorizerFunction", new FunctionProps {
    Runtime = Runtime.NODEJS_14_X,
    Handler = "index.handler",
    Code = AssetCode.FromAsset(Join(__dirname, "integ.request-authorizer.handler"))
});

var restapi = new RestApi(stack, "MyRestApi", new RestApiProps { CloudWatchRole = true });

var authorizer = new RequestAuthorizer(stack, "MyAuthorizer", new RequestAuthorizerProps {
    Handler = authorizerFn,
    IdentitySources = new [] { IdentitySource.Header("Authorization"), IdentitySource.QueryString("allow") }
});

var secondAuthorizer = new RequestAuthorizer(stack, "MySecondAuthorizer", new RequestAuthorizerProps {
    Handler = authorizerFn,
    IdentitySources = new [] { IdentitySource.Header("Authorization"), IdentitySource.QueryString("allow") }
});

restapi.Root.AddMethod("ANY", new MockIntegration(new IntegrationOptions {
    IntegrationResponses = new [] { new IntegrationResponse { StatusCode = "200" } },
    PassthroughBehavior = PassthroughBehavior.NEVER,
    RequestTemplates = new Dictionary<string, string> {
        { "application/json", "{ \"statusCode\": 200 }" }
    }
}), new MethodOptions {
    MethodResponses = new [] { new MethodResponse { StatusCode = "200" } },
    Authorizer = authorizer
});

restapi.Root.ResourceForPath("auth").AddMethod("ANY", new MockIntegration(new IntegrationOptions {
    IntegrationResponses = new [] { new IntegrationResponse { StatusCode = "200" } },
    PassthroughBehavior = PassthroughBehavior.NEVER,
    RequestTemplates = new Dictionary<string, string> {
        { "application/json", "{ \"statusCode\": 200 }" }
    }
}), new MethodOptions {
    MethodResponses = new [] { new MethodResponse { StatusCode = "200" } },
    Authorizer = secondAuthorizer
});

Synopsis

Fields

NEVER

Rejects unmapped content types with an HTTP 415 'Unsupported Media Type' response.

value__
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.

Fields

NEVER

Rejects unmapped content types with an HTTP 415 'Unsupported Media Type' response.

public const PassthroughBehavior NEVER
Field Value
Type Description
PassthroughBehavior

value__

public int value__
Field Value
Type Description
System.Int32

WHEN_NO_MATCH

Passes the request body for unmapped content types through to the integration back end without transformation.

public const PassthroughBehavior WHEN_NO_MATCH
Field Value
Type Description
PassthroughBehavior

WHEN_NO_TEMPLATES

Allows pass-through when the integration has NO content types mapped to templates.

public const PassthroughBehavior WHEN_NO_TEMPLATES
Field Value
Type Description
PassthroughBehavior
Remarks

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

Back to top Generated by DocFX