# withGatewayPathRoute

- Module: [Aspire.Hosting.Kubernetes](/reference/api/typescript/aspire.hosting.kubernetes.md)
- Version: `13.4.0-preview.1.26281.18`
- Kind: `method`
- Source: [GitHub](https://github.com/microsoft/aspire)

Adds a path-based routing rule to the gateway. The rule matches all hosts and routes traffic matching the specified path to the given endpoint's backing Kubernetes service. This generates an `HTTPRoute` resource attached to the Gateway.

## Definition

```typescript
interface KubernetesGatewayResource {
  // ... omitted for brevity
  withGatewayPathRoute(
    path: string,
    endpoint: EndpointReference,
    pathType?: GatewayPathMatchType): KubernetesGatewayResource
}
```

## Parameters

- `path` (`string`)
- `endpoint` (`EndpointReference`)
- `pathType` ([GatewayPathMatchType](/reference/api/typescript/aspire.hosting.kubernetes/gatewaypathmatchtype.md)) `optional` `= PathPrefix`

## Returns

[KubernetesGatewayResource](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesgatewayresource.md) `builder`

## Applies to

- [KubernetesGatewayResource](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesgatewayresource.md)
