interface WebSocketApiProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Apigatewayv2.WebSocketApiProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigatewayv2#WebSocketApiProps |
Java | software.amazon.awscdk.services.apigatewayv2.WebSocketApiProps |
Python | aws_cdk.aws_apigatewayv2.WebSocketApiProps |
TypeScript (source) | aws-cdk-lib » aws_apigatewayv2 » WebSocketApiProps |
Props for WebSocket API.
Example
import { WebSocketLambdaAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
// This function handles your auth logic
declare const authHandler: lambda.Function;
// This function handles your WebSocket requests
declare const handler: lambda.Function;
const authorizer = new WebSocketLambdaAuthorizer('Authorizer', authHandler);
const integration = new WebSocketLambdaIntegration(
'Integration',
handler,
);
new apigwv2.WebSocketApi(this, 'WebSocketApi', {
connectRouteOptions: {
integration,
authorizer,
},
});
Properties
Name | Type | Description |
---|---|---|
api | Web | An API key selection expression. |
api | string | Name for the WebSocket API resource. |
connect | Web | Options to configure a '$connect' route. |
default | Web | Options to configure a '$default' route. |
description? | string | The description of the API. |
disconnect | Web | Options to configure a '$disconnect' route. |
route | string | The route selection expression for the API. |
apiKeySelectionExpression?
Type:
Web
(optional, default: Key is not required to access these APIs)
An API key selection expression.
Providing this option will require an API Key be provided to access the API.
apiName?
Type:
string
(optional, default: id of the WebSocketApi construct.)
Name for the WebSocket API resource.
connectRouteOptions?
Type:
Web
(optional, default: no '$connect' route configured)
Options to configure a '$connect' route.
defaultRouteOptions?
Type:
Web
(optional, default: no '$default' route configured)
Options to configure a '$default' route.
description?
Type:
string
(optional, default: none)
The description of the API.
disconnectRouteOptions?
Type:
Web
(optional, default: no '$disconnect' route configured)
Options to configure a '$disconnect' route.
routeSelectionExpression?
Type:
string
(optional, default: '$request.body.action')
The route selection expression for the API.