# KubernetesGatewayResource.withGatewayPathRoute

- Module: [Aspire.Hosting.Kubernetes](/reference/api/typescript/aspire.hosting.kubernetes.md)
- Defined on: [KubernetesGatewayResource](/reference/api/typescript/aspire.hosting.kubernetes/kubernetesgatewayresource.md)
- Version: `13.4.0-preview.1.26281.18`
- Kind: `method`

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;
}
```

## Signature

```typescript
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`

## Defined on

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