# WebSocketRouteIntegration

The interface that various route integration classes will inherit.

Superclass of: [WebSocketAwsIntegration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2_integrations.WebSocketAwsIntegration.html), [WebSocketLambdaIntegration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2_integrations.WebSocketLambdaIntegration.html), WebSocketMockIntegration

- Source: [`aws-apigatewayv2/lib/websocket/integration.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/websocket/integration.ts#L242)
- Type last changed: v2.112.0 · 1 Dec 2023

## Example

TypeScript:

```ts
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi');
new apigwv2.WebSocketStage(this, 'mystage', {
  webSocketApi,
  stageName: 'dev',
  autoDeploy: true,
});

declare const messageHandler: lambda.Function;
webSocketApi.addRoute('sendMessage', {
  integration: new WebSocketLambdaIntegration('SendMessageIntegration', messageHandler),
});
```

Python:

```python
from aws_cdk.aws_apigatewayv2_integrations import WebSocketLambdaIntegration

# message_handler: lambda.Function

web_socket_api = apigwv2.WebSocketApi(self, "mywsapi")
apigwv2.WebSocketStage(self, "mystage",
    web_socket_api=web_socket_api,
    stage_name="dev",
    auto_deploy=True
)
web_socket_api.add_route("sendMessage",
    integration=WebSocketLambdaIntegration("SendMessageIntegration", message_handler)
)
```

Java:

```java
import software.amazon.awscdk.aws_apigatewayv2_integrations.WebSocketLambdaIntegration;

Function messageHandler;

WebSocketApi webSocketApi = new WebSocketApi(this, "mywsapi");
WebSocketStage.Builder.create(this, "mystage")
        .webSocketApi(webSocketApi)
        .stageName("dev")
        .autoDeploy(true)
        .build();
webSocketApi.addRoute("sendMessage", WebSocketRouteOptions.builder()
        .integration(new WebSocketLambdaIntegration("SendMessageIntegration", messageHandler))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AwsApigatewayv2Integrations;

Function messageHandler;

var webSocketApi = new WebSocketApi(this, "mywsapi");
new WebSocketStage(this, "mystage", new WebSocketStageProps {
    WebSocketApi = webSocketApi,
    StageName = "dev",
    AutoDeploy = true
});
webSocketApi.AddRoute("sendMessage", new WebSocketRouteOptions {
    Integration = new WebSocketLambdaIntegration("SendMessageIntegration", messageHandler)
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"

var messageHandler Function

webSocketApi := apigwv2.NewWebSocketApi(this, jsii.String("mywsapi"))
apigwv2.NewWebSocketStage(this, jsii.String("mystage"), &WebSocketStageProps{
	WebSocketApi: WebSocketApi,
	StageName: jsii.String("dev"),
	AutoDeploy: jsii.Boolean(true),
})
webSocketApi.AddRoute(jsii.String("sendMessage"), &WebSocketRouteOptions{
	Integration: awscdk.NewWebSocketLambdaIntegration(jsii.String("SendMessageIntegration"), messageHandler),
})
```

## Initializer

TypeScript:

```ts
new WebSocketRouteIntegration(id: string)
```

Python:

```python
WebSocketRouteIntegration(id: str)
```

Java:

```java
new WebSocketRouteIntegration(String id)
```

C# / .NET:

```csharp
new WebSocketRouteIntegration(string id)
```

Golang:

```go
NewWebSocketRouteIntegration(Id *string)
```

## Methods

- `bind(options: WebSocketRouteIntegrationBindOptions): WebSocketRouteIntegrationConfig` — Bind this integration to the route.
