# HttpGatewayRoutePathMatch

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

Obtainable from: HttpGatewayRoutePathMatch.exactly, HttpGatewayRoutePathMatch.regex, HttpGatewayRoutePathMatch.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#L134)

## Example

TypeScript:

```ts
declare const gateway: appmesh.VirtualGateway;
declare const virtualService: appmesh.VirtualService;

gateway.addGatewayRoute('gateway-route-http-2', {
  routeSpec: appmesh.GatewayRouteSpec.http({
    routeTarget: virtualService,
    match: {
      // This rewrites the path from '/test' to '/rewrittenPath'.
      path: appmesh.HttpGatewayRoutePathMatch.exactly('/test', '/rewrittenPath'),
    },
  }),
});
```

Python:

```python
# gateway: appmesh.VirtualGateway
# virtual_service: appmesh.VirtualService

gateway.add_gateway_route("gateway-route-http-2",
    route_spec=appmesh.GatewayRouteSpec.http(
        route_target=virtual_service,
        match=appmesh.HttpGatewayRouteMatch(
            # This rewrites the path from '/test' to '/rewrittenPath'.
            path=appmesh.HttpGatewayRoutePathMatch.exactly("/test", "/rewrittenPath")
        )
    )
)
```

Java:

```java
VirtualGateway gateway;
VirtualService virtualService;

gateway.addGatewayRoute("gateway-route-http-2", GatewayRouteBaseProps.builder()
        .routeSpec(GatewayRouteSpec.http(HttpGatewayRouteSpecOptions.builder()
                .routeTarget(virtualService)
                .match(HttpGatewayRouteMatch.builder()
                        // This rewrites the path from '/test' to '/rewrittenPath'.
                        .path(HttpGatewayRoutePathMatch.exactly("/test", "/rewrittenPath"))
                        .build())
                .build()))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
VirtualGateway gateway;
VirtualService virtualService;

gateway.AddGatewayRoute("gateway-route-http-2", new GatewayRouteBaseProps {
    RouteSpec = GatewayRouteSpec.Http(new HttpGatewayRouteSpecOptions {
        RouteTarget = virtualService,
        Match = new HttpGatewayRouteMatch {
            // This rewrites the path from '/test' to '/rewrittenPath'.
            Path = HttpGatewayRoutePathMatch.Exactly("/test", "/rewrittenPath")
        }
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var gateway VirtualGateway
var virtualService VirtualService

gateway.addGatewayRoute(jsii.String("gateway-route-http-2"), &GatewayRouteBaseProps{
	RouteSpec: appmesh.GatewayRouteSpec_Http(&HttpGatewayRouteSpecOptions{
		RouteTarget: virtualService,
		Match: &HttpGatewayRouteMatch{
			// This rewrites the path from '/test' to '/rewrittenPath'.
			Path: appmesh.HttpGatewayRoutePathMatch_Exactly(jsii.String("/test"), jsii.String("/rewrittenPath")),
		},
	}),
})
```

## Initializer

TypeScript:

```ts
new HttpGatewayRoutePathMatch()
```

Python:

```python
HttpGatewayRoutePathMatch()
```

Java:

```java
new HttpGatewayRoutePathMatch()
```

C# / .NET:

```csharp
new HttpGatewayRoutePathMatch()
```

Golang:

```go
NewHttpGatewayRoutePathMatch()
```

## Methods

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

- `exactly(path: string, rewriteTo?: string): HttpGatewayRoutePathMatch // 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.
  - `rewriteTo` — the value to substitute for the matched part of the path of the gateway request URL As a default, retains original request's URL path.

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

  **Parameters**

  - `regex` — the regex used to match the path.
  - `rewriteTo` — the value to substitute for the matched part of the path of the gateway request URL As a default, retains original request's URL path.

- `startsWith(prefix: string, rewriteTo?: string): HttpGatewayRoutePathMatch // 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.
  - `rewriteTo` — Specify either disabling automatic rewrite or rewriting to specified prefix path.
