# HttpRoutePathMatch

Defines HTTP route matching based on the URL path of the request.

Obtainable from: HttpRoutePathMatch.exactly, HttpRoutePathMatch.regex, HttpRoutePathMatch.startsWith

- Source: [`aws-appmesh/lib/http-route-path-match.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-appmesh/lib/http-route-path-match.ts#L28)

## Example

TypeScript:

```ts
declare const router: appmesh.VirtualRouter;
declare const node: appmesh.VirtualNode;

router.addRoute('route-http', {
  routeSpec: appmesh.RouteSpec.http({
    weightedTargets: [
      {
        virtualNode: node,
        weight: 50,
      },
      {
        virtualNode: node,
        weight: 50,
      },
    ],
    match: {
      path: appmesh.HttpRoutePathMatch.startsWith('/path-to-app'),
    },
  }),
});
```

Python:

```python
# router: appmesh.VirtualRouter
# node: appmesh.VirtualNode

router.add_route("route-http",
    route_spec=appmesh.RouteSpec.http(
        weighted_targets=[appmesh.WeightedTarget(
            virtual_node=node,
            weight=50
        ), appmesh.WeightedTarget(
            virtual_node=node,
            weight=50
        )
        ],
        match=appmesh.HttpRouteMatch(
            path=appmesh.HttpRoutePathMatch.starts_with("/path-to-app")
        )
    )
)
```

Java:

```java
VirtualRouter router;
VirtualNode node;

router.addRoute("route-http", RouteBaseProps.builder()
        .routeSpec(RouteSpec.http(HttpRouteSpecOptions.builder()
                .weightedTargets(List.of(WeightedTarget.builder()
                        .virtualNode(node)
                        .weight(50)
                        .build(), WeightedTarget.builder()
                        .virtualNode(node)
                        .weight(50)
                        .build()))
                .match(HttpRouteMatch.builder()
                        .path(HttpRoutePathMatch.startsWith("/path-to-app"))
                        .build())
                .build()))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualRouter router;
VirtualNode node;

router.AddRoute("route-http", new RouteBaseProps {
    RouteSpec = RouteSpec.Http(new HttpRouteSpecOptions {
        WeightedTargets = new [] { new WeightedTarget {
            VirtualNode = node,
            Weight = 50
        }, new WeightedTarget {
            VirtualNode = node,
            Weight = 50
        } },
        Match = new HttpRouteMatch {
            Path = HttpRoutePathMatch.StartsWith("/path-to-app")
        }
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var router VirtualRouter
var node VirtualNode

router.addRoute(jsii.String("route-http"), &RouteBaseProps{
	RouteSpec: appmesh.RouteSpec_Http(&HttpRouteSpecOptions{
		WeightedTargets: []WeightedTarget{
			&WeightedTarget{
				VirtualNode: node,
				Weight: jsii.Number(50),
			},
			&WeightedTarget{
				VirtualNode: node,
				Weight: jsii.Number(50),
			},
		},
		Match: &HttpRouteMatch{
			Path: appmesh.HttpRoutePathMatch_StartsWith(jsii.String("/path-to-app")),
		},
	}),
})
```

## Initializer

TypeScript:

```ts
new HttpRoutePathMatch()
```

Python:

```python
HttpRoutePathMatch()
```

Java:

```java
new HttpRoutePathMatch()
```

C# / .NET:

```csharp
new HttpRoutePathMatch()
```

Golang:

```go
NewHttpRoutePathMatch()
```

## Methods

- `bind(scope: Construct): HttpRoutePathMatchConfig` — Returns the route path match configuration.

- `exactly(path: string): HttpRoutePathMatch // chainable` (static) — The value of the path must match the specified value exactly.

  The provided `path` must start with the '/' character.

  **Parameters**

  - `path` — the exact path to match on.

- `regex(regex: string): HttpRoutePathMatch // chainable` (static) — The value of the path must match the specified regex.

  **Parameters**

  - `regex` — the regex used to match the path.

- `startsWith(prefix: string): HttpRoutePathMatch // chainable` (static) — The value of the path must match the specified prefix.

  **Parameters**

  - `prefix` — the value to use to match the beginning of the path part of the URL of the request.
