# withGatewayHostRoute

- 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 host-and-path-based routing rule to the gateway. The rule matches traffic for the specified host and path, routing it to the given endpoint's backing Kubernetes service. This generates an `HTTPRoute` resource with a `hostnames` filter.

## Definition

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

## Parameters

- `host` (`string`)
- `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)
