# HttpRouteKey

HTTP route in APIGateway is a combination of the HTTP method and the path component.

This class models that combination.

Obtainable from: HttpRouteKey.DEFAULT, HttpRouteKey.with

- Source: [`aws-apigatewayv2/lib/http/route.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/http/route.ts#L81)
- 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';
const httpRouteKey = apigatewayv2.HttpRouteKey.with('path', /* all optional props */ apigatewayv2.HttpMethod.ANY);
```

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

http_route_key = apigatewayv2.HttpRouteKey.with("path", apigatewayv2.HttpMethod.ANY)
```

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.*;

HttpRouteKey httpRouteKey = HttpRouteKey.with("path", HttpMethod.ANY);
```

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;

var httpRouteKey = HttpRouteKey.With("path", HttpMethod.ANY);
```

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"

httpRouteKey := awscdk.Aws_apigatewayv2.HttpRouteKey_With(jsii.String("path"), awscdk.Aws_apigatewayv2.HttpMethod_ANY)
```

## Properties

- `DEFAULT`: [HttpRouteKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteKey.html) (static) — The catch-all route of the API, i.e., when no other routes match.

- `key`: string — The key to the RouteKey as recognized by APIGateway.

- `method`: [HttpMethod](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpMethod.html) — The method of the route.

- `path`: string — The path part of this RouteKey.

  Returns `undefined` when `RouteKey.DEFAULT` is used.

## Methods

- `with(path: string, method?: HttpMethod): HttpRouteKey // chainable` (static) — Create a route key with the combination of the path and the method.

  **Parameters**

  - `method` — default is 'ANY'.
