# WebSocketRouteProps

Properties to initialize a new Route.

Extends: [WebSocketRouteOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteOptions.html)
Used as props by: [WebSocketRoute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRoute.html)

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

## Example

TypeScript:

```ts
// 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 webSocketRouteProps: apigatewayv2.WebSocketRouteProps = {
  integration: webSocketRouteIntegration,
  routeKey: 'routeKey',
  webSocketApi: webSocketApi,

  // the properties below are optional
  apiKeyRequired: false,
  authorizer: webSocketRouteAuthorizer,
  returnResponse: false,
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_apigatewayv2 as apigatewayv2

# web_socket_api: apigatewayv2.WebSocketApi
# web_socket_route_authorizer: apigatewayv2.IWebSocketRouteAuthorizer
# web_socket_route_integration: apigatewayv2.WebSocketRouteIntegration

web_socket_route_props = apigatewayv2.WebSocketRouteProps(
    integration=web_socket_route_integration,
    route_key="routeKey",
    web_socket_api=web_socket_api,

    # the properties below are optional
    api_key_required=False,
    authorizer=web_socket_route_authorizer,
    return_response=False
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.apigatewayv2.*;

WebSocketApi webSocketApi;
IWebSocketRouteAuthorizer webSocketRouteAuthorizer;
WebSocketRouteIntegration webSocketRouteIntegration;

WebSocketRouteProps webSocketRouteProps = WebSocketRouteProps.builder()
        .integration(webSocketRouteIntegration)
        .routeKey("routeKey")
        .webSocketApi(webSocketApi)

        // the properties below are optional
        .apiKeyRequired(false)
        .authorizer(webSocketRouteAuthorizer)
        .returnResponse(false)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Apigatewayv2;

WebSocketApi webSocketApi;
IWebSocketRouteAuthorizer webSocketRouteAuthorizer;
WebSocketRouteIntegration webSocketRouteIntegration;

var webSocketRouteProps = new WebSocketRouteProps {
    Integration = webSocketRouteIntegration,
    RouteKey = "routeKey",
    WebSocketApi = webSocketApi,

    // the properties below are optional
    ApiKeyRequired = false,
    Authorizer = webSocketRouteAuthorizer,
    ReturnResponse = false
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

var webSocketApi WebSocketApi
var webSocketRouteAuthorizer IWebSocketRouteAuthorizer
var webSocketRouteIntegration WebSocketRouteIntegration

webSocketRouteProps := &WebSocketRouteProps{
	Integration: webSocketRouteIntegration,
	RouteKey: jsii.String("routeKey"),
	WebSocketApi: webSocketApi,

	// the properties below are optional
	ApiKeyRequired: jsii.Boolean(false),
	Authorizer: webSocketRouteAuthorizer,
	ReturnResponse: jsii.Boolean(false),
}
```

## Properties

- `apiKeyRequired`: boolean = false — Whether the route requires an API Key to be provided.

- `authorizer`: [IWebSocketRouteAuthorizer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketRouteAuthorizer.html) — The authorize to this route.

  **Default:** No Authorizer

  You can only set authorizer to a $connect route.

- `integration`: [WebSocketRouteIntegration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteIntegration.html) (required) — The integration to be configured on this route.

- `returnResponse`: boolean = false — Should the route send a response to the client.

- `routeKey`: string (required) — The key to this route.

- `webSocketApi`: [IWebSocketApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketApi.html) (required) — The API the route is associated with.
