interface GatewayResponseOptions
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGateway.GatewayResponseOptions |
Java | software.amazon.awscdk.services.apigateway.GatewayResponseOptions |
Python | aws_cdk.aws_apigateway.GatewayResponseOptions |
TypeScript (source) | @aws-cdk/aws-apigateway » GatewayResponseOptions |
Options to add gateway response.
Example
const api = new apigateway.RestApi(this, 'books-api');
api.addGatewayResponse('test-response', {
type: apigateway.ResponseType.ACCESS_DENIED,
statusCode: '500',
responseHeaders: {
'Access-Control-Allow-Origin': "test.com",
'test-key': 'test-value'
},
templates: {
'application/json': '{ "message": $context.error.messageString, "statusCode": "488", "type": "$context.error.responseType" }'
}
});
Properties
Name | Type | Description |
---|---|---|
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. |
type
Type:
Response
Response type to associate with gateway response.
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.