# KubernetesIngressResource.WithIngressHostAndPath

- Module: [Aspire.Hosting.Kubernetes](/reference/api/go/aspire.hosting.kubernetes.md)
- Defined on: [KubernetesIngressResource](/reference/api/go/aspire.hosting.kubernetes/kubernetesingressresource.md)
- Version: `13.6.5-preview.1.26559.7`
- Kind: `method`

Adds a host-scoped path rule to the ingress. The rule matches traffic for the specified host and path, forwarding it to the given endpoint's backing Kubernetes service.

## Definition

```go
type KubernetesIngressResource interface {
    // ... omitted for brevity
    WithIngressHostAndPath(
        host string,
        path string,
        endpoint EndpointReference,
        options ...*WithIngressHostAndPathOptions,
    ) KubernetesIngressResource
}
```

## Signature

```go
WithIngressHostAndPath(
    host string,
    path string,
    endpoint EndpointReference,
    options ...*WithIngressHostAndPathOptions,
) KubernetesIngressResource
```

## Parameters

- `host` (`string`) -- The hostname to match (e.g., `"api.example.com"`).
- `path` (`string`) -- The URL path to match (e.g., `"/"` or `"/api"`). Must start with `/`.
- `endpoint` (`EndpointReference`) -- The endpoint reference identifying the target service and port.
- `options` (`...*WithIngressHostAndPathOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*WithIngressHostAndPathOptions` argument.

- `PathType` ([`*IngressPathType`](/reference/api/go/aspire.hosting.kubernetes/ingresspathtype.md)) -- The path matching strategy. Defaults to `Prefix`.

## Returns

[`KubernetesIngressResource`](/reference/api/go/aspire.hosting.kubernetes/kubernetesingressresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [KubernetesIngressResource](/reference/api/go/aspire.hosting.kubernetes/kubernetesingressresource.md) -- `handle`
