# KubernetesGatewayResource.withGatewayHostRoute

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

## Signature

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

## Defined on

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