class WebSocketRoute (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Apigatewayv2.WebSocketRoute |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigatewayv2#WebSocketRoute |
Java | software.amazon.awscdk.services.apigatewayv2.WebSocketRoute |
Python | aws_cdk.aws_apigatewayv2.WebSocketRoute |
TypeScript (source) | aws-cdk-lib » aws_apigatewayv2 » WebSocketRoute |
Implements
IConstruct
, IDependable
, IResource
, IWeb
, IRoute
Route class that creates the Route for API Gateway WebSocket API.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_apigatewayv2 as apigatewayv2 } from 'aws-cdk-lib';
declare const webSocketApi: apigatewayv2.WebSocketApi;
declare const webSocketRouteAuthorizer: apigatewayv2.IWebSocketRouteAuthorizer;
declare const webSocketRouteIntegration: apigatewayv2.WebSocketRouteIntegration;
const webSocketRoute = new apigatewayv2.WebSocketRoute(this, 'MyWebSocketRoute', {
integration: webSocketRouteIntegration,
routeKey: 'routeKey',
webSocketApi: webSocketApi,
// the properties below are optional
apiKeyRequired: false,
authorizer: webSocketRouteAuthorizer,
returnResponse: false,
});
Initializer
new WebSocketRoute(scope: Construct, id: string, props: WebSocketRouteProps)
Parameters
- scope
Construct
- id
string
- props
Web
Socket Route Props
Construct Props
Name | Type | Description |
---|---|---|
integration | Web | The integration to be configured on this route. |
route | string | The key to this route. |
web | IWeb | The API the route is associated with. |
api | boolean | Whether the route requires an API Key to be provided. |
authorizer? | IWeb | The authorize to this route. |
return | boolean | Should the route send a response to the client. |
integration
Type:
Web
The integration to be configured on this route.
routeKey
Type:
string
The key to this route.
webSocketApi
Type:
IWeb
The API the route is associated with.
apiKeyRequired?
Type:
boolean
(optional, default: false)
Whether the route requires an API Key to be provided.
authorizer?
Type:
IWeb
(optional, default: No Authorizer)
The authorize to this route.
You can only set authorizer to a $connect route.
returnResponse?
Type:
boolean
(optional, default: false)
Should the route send a response to the client.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
route | string | Id of the Route. |
route | string | The key to this route. |
stack | Stack | The stack in which this resource is defined. |
web | IWeb | The WebSocket API associated with this route. |
integration | string | Integration response ID. |
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.
routeId
Type:
string
Id of the Route.
routeKey
Type:
string
The key to this route.
stack
Type:
Stack
The stack in which this resource is defined.
webSocketApi
Type:
IWeb
The WebSocket API associated with this route.
integrationResponseId?
Type:
string
(optional)
Integration response ID.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
applyRemovalPolicy(policy)
public 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
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.