# YarpRouteExtensions Methods

- Package: [Aspire.Hosting.Yarp](/reference/api/csharp/aspire.hosting.yarp.md)
- Type: [YarpRouteExtensions](/reference/api/csharp/aspire.hosting.yarp/yarprouteextensions.md)
- Kind: `Methods`
- Members: `11`

Provides extension methods for configuring a YARP destination

## WithMatch(YarpRoute, RouteMatch)

- Name: `WithMatch(YarpRoute, RouteMatch)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs)

Set the parameters used to match requests.

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMatch(
        this YarpRoute route,
        RouteMatch match)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `match` (`RouteMatch`)

## Remarks

This overload is not available in polyglot app hosts. Use the DTO-based overload or the specific match helper methods instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithMatchHeaders(YarpRoute, RouteHeader[])

- Name: `WithMatchHeaders(YarpRoute, RouteHeader[])`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs)

Only match requests that contain all of these headers.

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMatchHeaders(
        this YarpRoute route,
        params RouteHeader[] headers)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `headers` (`RouteHeader[]`)

## Remarks

This overload is not available in polyglot app hosts. Use the DTO-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithMatchHosts(YarpRoute, string[])

- Name: `WithMatchHosts(YarpRoute, string[])`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L124-L125)

Only match requests with the given Host header. Supports wildcards and ports. For unicode host names, do not use punycode.

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMatchHosts(
        this YarpRoute route,
        params string[] hosts)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `hosts` (`string[]`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithMatchMethods(YarpRoute, string[])

- Name: `WithMatchMethods(YarpRoute, string[])`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L90-L91)

Only match requests that use these optional HTTP methods. E.g. GET, POST.

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMatchMethods(
        this YarpRoute route,
        params string[] methods)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `methods` (`string[]`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithMatchPath(YarpRoute, string)

- Name: `WithMatchPath(YarpRoute, string)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L80-L81)

Only match requests with the given Path pattern.

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMatchPath(
        this YarpRoute route,
        string path)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `path` (`string`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithMatchRouteQueryParameter(YarpRoute, RouteQueryParameter[])

- Name: `WithMatchRouteQueryParameter(YarpRoute, RouteQueryParameter[])`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs)

Only match requests that contain all of these query parameters.

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMatchRouteQueryParameter(
        this YarpRoute route,
        params RouteQueryParameter[] queryParameters)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `queryParameters` (`RouteQueryParameter[]`)

## Remarks

This overload is not available in polyglot app hosts. Use the DTO-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithMaxRequestBodySize(YarpRoute, long)

- Name: `WithMaxRequestBodySize(YarpRoute, long)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L169-L170)

Set the MaxRequestBodySize for the destination

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMaxRequestBodySize(
        this YarpRoute route,
        long maxRequestBodySize)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `maxRequestBodySize` (`long`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithMetadata(YarpRoute, IReadOnlyDictionary<string, string>)

- Name: `WithMetadata(YarpRoute, IReadOnlyDictionary<string, string>)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L179-L180)

Set the Metadata of the destination

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithMetadata(
        this YarpRoute route,
        IReadOnlyDictionary<string, string>? metadata)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `metadata` (`IReadOnlyDictionary<string, string>`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithOrder(YarpRoute, int?)

- Name: `WithOrder(YarpRoute, int?)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L159-L160)

Set the order for the destination

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithOrder(
        this YarpRoute route,
        int? order)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `order` (`int?`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithTransform(YarpRoute, Action<IDictionary<string, string>>)

- Name: `WithTransform(YarpRoute, Action<IDictionary<string, string>>)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L200-L209)

Add a new transform to the destination

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithTransform(
        this YarpRoute route,
        Action<IDictionary<string, string>> createTransform)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `createTransform` (`Action<IDictionary<string, string>>`)

## Remarks

This method is not available in polyglot app hosts. Use [YarpRouteExtensions.WithTransforms(YarpRoute, IReadOnlyList<IReadOnlyDictionary<string, string>>)](/reference/api/csharp/aspire.hosting.yarp/yarprouteextensions/methods.md#withtransforms-yarproute-ireadonlylist-ireadonlydictionary-string-string) or the transform-specific helpers instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithTransforms(YarpRoute, IReadOnlyList<IReadOnlyDictionary<string, string>>)

- Name: `WithTransforms(YarpRoute, IReadOnlyList<IReadOnlyDictionary<string, string>>)`
- Modifiers: `extension`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpRoute.cs#L189-L190)

Set the Transforms of the destination

```csharp
public static class YarpRouteExtensions
{
    public static YarpRoute WithTransforms(
        this YarpRoute route,
        IReadOnlyList<IReadOnlyDictionary<string, string>>? transforms)
    {
        // ...
    }
}
```

## Parameters

- `route` ([YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md))
- `transforms` (`IReadOnlyList<IReadOnlyDictionary<string, string>>`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
