class GatewayResponse (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGateway.GatewayResponse |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#GatewayResponse |
Java | software.amazon.awscdk.services.apigateway.GatewayResponse |
Python | aws_cdk.aws_apigateway.GatewayResponse |
TypeScript (source) | aws-cdk-lib » aws_apigateway » GatewayResponse |
Implements
IConstruct
, IDependable
, IResource
, IGateway
Configure the response received by clients, produced from the API Gateway backend.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_apigateway as apigateway } from 'aws-cdk-lib';
declare const responseType: apigateway.ResponseType;
declare const restApi: apigateway.RestApi;
const gatewayResponse = new apigateway.GatewayResponse(this, 'MyGatewayResponse', {
restApi: restApi,
type: responseType,
// the properties below are optional
responseHeaders: {
responseHeadersKey: 'responseHeaders',
},
statusCode: 'statusCode',
templates: {
templatesKey: 'templates',
},
});
Initializer
new GatewayResponse(scope: Construct, id: string, props: GatewayResponseProps)
Parameters
- scope
Construct
- id
string
- props
Gateway
Response Props
Construct Props
Name | Type | Description |
---|---|---|
rest | IRest | Rest api resource to target. |
type | Response | Response type to associate with gateway response. |
response | { [string]: string } | Custom headers parameters for response. |
status | string | Http status code for response. |
templates? | { [string]: string } | Custom templates to get mapped as response. |
restApi
Type:
IRest
Rest api resource to target.
type
Type:
Response
Response type to associate with gateway response.
See also: https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html
responseHeaders?
Type:
{ [string]: string }
(optional, default: no headers)
Custom headers parameters for response.
statusCode?
Type:
string
(optional, default: standard http status code for the response type.)
Http status code for response.
templates?
Type:
{ [string]: string }
(optional, default: Response from api will be returned without applying any transformation.)
Custom templates to get mapped as response.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.