# HttpGatewayRouteMatch

The criterion for determining a request match for this GatewayRoute.

- Source: [`aws-appmesh/lib/gateway-route-spec.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-appmesh/lib/gateway-route-spec.ts#L66)
- Type last changed: v2.77.0 · 26 Apr 2023

## 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")),
		},
	}),
})
```

## Properties

- `headers`: [HeaderMatch](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appmesh.HeaderMatch.html)[] — Specifies the client request headers to match on.

  **Default:** do not match on headers

  All specified headers
  must match for the gateway route to match.

- `hostname`: [GatewayRouteHostnameMatch](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appmesh.GatewayRouteHostnameMatch.html) — The gateway route host name to be matched on.

  **Default:** do not match on host name

- `method`: [HttpRouteMethod](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appmesh.HttpRouteMethod.html) — The method to match on.

  **Default:** do not match on method

- `path`: [HttpGatewayRoutePathMatch](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appmesh.HttpGatewayRoutePathMatch.html) — Specify how to match requests based on the 'path' part of their URL.

  **Default:** matches requests with any path

- `port`: number — The port number to match on.

  **Default:** no default port

- `queryParameters`: [QueryParameterMatch](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appmesh.QueryParameterMatch.html)[] — The query parameters to match on.

  **Default:** do not match on query parameters

  All specified query parameters must match for the route to match.

- `rewriteRequestHostname`: boolean = true — When `true`, rewrites the original request received at the Virtual Gateway to the destination Virtual Service name.

  When `false`, retains the original hostname from the request.
