# YarpRoute

- Module: [Aspire.Hosting.Yarp](/reference/api/typescript/aspire.hosting.yarp.md)
- Version: `13.2.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

## Definition

```typescript
interface YarpRoute {
  withMatch(match: YarpRouteMatch): YarpRoute;
  withMatchHeaders(headers: YarpRouteHeaderMatch[]): YarpRoute;
  withMatchHosts(hosts: string[]): YarpRoute;
  withMatchMethods(methods: string[]): YarpRoute;
  withMatchPath(path: string): YarpRoute;
  withMatchRouteQueryParameter(queryParameters: YarpRouteQueryParameterMatch[]): YarpRoute;
  withMaxRequestBodySize(maxRequestBodySize: number): YarpRoute;
  withMetadata(metadata: Dict<string,string>): YarpRoute;
  withOrder(order: number): YarpRoute;
  withTransform(transform: Dict<string,string>): YarpRoute;
  withTransformClientCertHeader(headerName: string): YarpRoute;
  withTransformCopyRequestHeaders(copy?: boolean): YarpRoute;
  withTransformCopyResponseHeaders(copy?: boolean): YarpRoute;
  withTransformCopyResponseTrailers(copy?: boolean): YarpRoute;
  withTransformForwarded(
      useHost?: boolean,
      useProto?: boolean,
      forFormat?: NodeFormat,
      byFormat?: NodeFormat,
      action?: ForwardedTransformActions): YarpRoute;
  withTransformHttpMethodChange(
      fromHttpMethod: string,
      toHttpMethod: string): YarpRoute;
  withTransformPathPrefix(prefix: string): YarpRoute;
  withTransformPathRemovePrefix(prefix: string): YarpRoute;
  withTransformPathRouteValues(pattern: string): YarpRoute;
  withTransformPathSet(path: string): YarpRoute;
  withTransformQueryRemoveKey(queryKey: string): YarpRoute;
  withTransformQueryRouteValue(
      queryKey: string,
      routeValueKey: string,
      append?: boolean): YarpRoute;
  withTransformQueryValue(
      queryKey: string,
      value: string,
      append?: boolean): YarpRoute;
  withTransformRequestHeader(
      headerName: string,
      value: string,
      append?: boolean): YarpRoute;
  withTransformRequestHeaderRemove(headerName: string): YarpRoute;
  withTransformRequestHeaderRouteValue(
      headerName: string,
      routeValueKey: string,
      append?: boolean): YarpRoute;
  withTransformRequestHeadersAllowed(allowedHeaders: string[]): YarpRoute;
  withTransformResponseHeader(
      headerName: string,
      value: string,
      append?: boolean,
      condition?: ResponseCondition): YarpRoute;
  withTransformResponseHeaderRemove(
      headerName: string,
      condition?: ResponseCondition): YarpRoute;
  withTransformResponseHeadersAllowed(allowedHeaders: string[]): YarpRoute;
  withTransformResponseTrailer(
      headerName: string,
      value: string,
      append?: boolean,
      condition?: ResponseCondition): YarpRoute;
  withTransformResponseTrailerRemove(
      headerName: string,
      condition?: ResponseCondition): YarpRoute;
  withTransformResponseTrailersAllowed(allowedHeaders: string[]): YarpRoute;
  withTransforms(transforms: Dict<string,string>[]): YarpRoute;
  withTransformUseOriginalHostHeader(useOriginal?: boolean): YarpRoute;
  withTransformXForwarded(
      headerPrefix?: string,
      xDefault?: ForwardedTransformActions,
      xFor?: ForwardedTransformActions,
      xHost?: ForwardedTransformActions,
      xProto?: ForwardedTransformActions,
      xPrefix?: ForwardedTransformActions): YarpRoute;
}
```

## Methods

- [withMatch](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmatch.md) -- `method` -- Sets the route match criteria.
    ```typescript
  withMatch(match: YarpRouteMatch): YarpRoute
  ```
- [withMatchHeaders](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmatchheaders.md) -- `method` -- Matches requests that contain the specified headers.
    ```typescript
  withMatchHeaders(headers: YarpRouteHeaderMatch[]): YarpRoute
  ```
- [withMatchHosts](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmatchhosts.md) -- `method` -- Matches requests that contain the specified host headers.
    ```typescript
  withMatchHosts(hosts: string[]): YarpRoute
  ```
- [withMatchMethods](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmatchmethods.md) -- `method` -- Matches requests that use the specified HTTP methods.
    ```typescript
  withMatchMethods(methods: string[]): YarpRoute
  ```
- [withMatchPath](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmatchpath.md) -- `method` -- Matches requests with the specified path pattern.
    ```typescript
  withMatchPath(path: string): YarpRoute
  ```
- [withMatchRouteQueryParameter](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmatchroutequeryparameter.md) -- `method` -- Matches requests that contain the specified query parameters.
    ```typescript
  withMatchRouteQueryParameter(queryParameters: YarpRouteQueryParameterMatch[]): YarpRoute
  ```
- [withMaxRequestBodySize](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmaxrequestbodysize.md) -- `method` -- Sets the maximum request body size for the route.
    ```typescript
  withMaxRequestBodySize(maxRequestBodySize: number): YarpRoute
  ```
- [withMetadata](/reference/api/typescript/aspire.hosting.yarp/yarproute/withmetadata.md) -- `method` -- Sets metadata for the route.
    ```typescript
  withMetadata(metadata: Dict<string,string>): YarpRoute
  ```
- [withOrder](/reference/api/typescript/aspire.hosting.yarp/yarproute/withorder.md) -- `method` -- Sets the route order.
    ```typescript
  withOrder(order: number): YarpRoute
  ```
- [withTransform](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransform.md) -- `method` -- Adds a transform to the route.
    ```typescript
  withTransform(transform: Dict<string,string>): YarpRoute
  ```
- [withTransformClientCertHeader](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformclientcertheader.md) -- `method` -- Adds the transform which will set the given header with the Base64 encoded client certificate.
    ```typescript
  withTransformClientCertHeader(headerName: string): YarpRoute
  ```
- [withTransformCopyRequestHeaders](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformcopyrequestheaders.md) -- `method` -- Adds the transform which will enable or suppress copying request headers to the proxy request.
    ```typescript
  withTransformCopyRequestHeaders(copy?: boolean): YarpRoute
  ```
- [withTransformCopyResponseHeaders](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformcopyresponseheaders.md) -- `method` -- Adds the transform which will enable or suppress copying response headers to the client response.
    ```typescript
  withTransformCopyResponseHeaders(copy?: boolean): YarpRoute
  ```
- [withTransformCopyResponseTrailers](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformcopyresponsetrailers.md) -- `method` -- Adds the transform which will enable or suppress copying response trailers to the client response.
    ```typescript
  withTransformCopyResponseTrailers(copy?: boolean): YarpRoute
  ```
- [withTransformForwarded](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformforwarded.md) -- `method` -- Adds the transform which will add the Forwarded header as defined by [RFC 7239](https://tools.ietf.org/html/rfc7239).
    ```typescript
  withTransformForwarded(useHost?: boolean, useProto?: boolean, forFormat?: NodeFormat, byFormat?: NodeFormat, action?: ForwardedTransformActions): YarpRoute
  ```
- [withTransformHttpMethodChange](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformhttpmethodchange.md) -- `method` -- Adds the transform that will replace the HTTP method if it matches.
    ```typescript
  withTransformHttpMethodChange(fromHttpMethod: string, toHttpMethod: string): YarpRoute
  ```
- [withTransformPathPrefix](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformpathprefix.md) -- `method` -- Adds the transform which will prefix the request path with the given value.
    ```typescript
  withTransformPathPrefix(prefix: string): YarpRoute
  ```
- [withTransformPathRemovePrefix](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformpathremoveprefix.md) -- `method` -- Adds the transform which will remove the matching prefix from the request path.
    ```typescript
  withTransformPathRemovePrefix(prefix: string): YarpRoute
  ```
- [withTransformPathRouteValues](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformpathroutevalues.md) -- `method` -- Adds the transform which will set the request path with route values.
    ```typescript
  withTransformPathRouteValues(pattern: string): YarpRoute
  ```
- [withTransformPathSet](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformpathset.md) -- `method` -- Adds the transform which sets the request path with the given value.
    ```typescript
  withTransformPathSet(path: string): YarpRoute
  ```
- [withTransformQueryRemoveKey](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformqueryremovekey.md) -- `method` -- Adds the transform that will remove the given query key.
    ```typescript
  withTransformQueryRemoveKey(queryKey: string): YarpRoute
  ```
- [withTransformQueryRouteValue](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformqueryroutevalue.md) -- `method` -- Adds the transform that will append or set the query parameter from a route value.
    ```typescript
  withTransformQueryRouteValue(queryKey: string, routeValueKey: string, append?: boolean): YarpRoute
  ```
- [withTransformQueryValue](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformqueryvalue.md) -- `method` -- Adds the transform that will append or set the query parameter from the given value.
    ```typescript
  withTransformQueryValue(queryKey: string, value: string, append?: boolean): YarpRoute
  ```
- [withTransformRequestHeader](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformrequestheader.md) -- `method` -- Adds the transform which will append or set the request header.
    ```typescript
  withTransformRequestHeader(headerName: string, value: string, append?: boolean): YarpRoute
  ```
- [withTransformRequestHeaderRemove](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformrequestheaderremove.md) -- `method` -- Adds the transform which will remove the request header.
    ```typescript
  withTransformRequestHeaderRemove(headerName: string): YarpRoute
  ```
- [withTransformRequestHeaderRouteValue](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformrequestheaderroutevalue.md) -- `method` -- Adds the transform which will append or set the request header from a route value.
    ```typescript
  withTransformRequestHeaderRouteValue(headerName: string, routeValueKey: string, append?: boolean): YarpRoute
  ```
- [withTransformRequestHeadersAllowed](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformrequestheadersallowed.md) -- `method` -- Adds the transform which will only copy the allowed request headers. Other transforms
    ```typescript
  withTransformRequestHeadersAllowed(allowedHeaders: string[]): YarpRoute
  ```
- [withTransformResponseHeader](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformresponseheader.md) -- `method` -- Adds the transform which will append or set the response header.
    ```typescript
  withTransformResponseHeader(headerName: string, value: string, append?: boolean, condition?: ResponseCondition): YarpRoute
  ```
- [withTransformResponseHeaderRemove](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformresponseheaderremove.md) -- `method` -- Adds the transform which will remove the response header.
    ```typescript
  withTransformResponseHeaderRemove(headerName: string, condition?: ResponseCondition): YarpRoute
  ```
- [withTransformResponseHeadersAllowed](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformresponseheadersallowed.md) -- `method` -- Adds the transform which will only copy the allowed response headers. Other transforms
    ```typescript
  withTransformResponseHeadersAllowed(allowedHeaders: string[]): YarpRoute
  ```
- [withTransformResponseTrailer](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformresponsetrailer.md) -- `method` -- Adds the transform which will append or set the response trailer.
    ```typescript
  withTransformResponseTrailer(headerName: string, value: string, append?: boolean, condition?: ResponseCondition): YarpRoute
  ```
- [withTransformResponseTrailerRemove](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformresponsetrailerremove.md) -- `method` -- Adds the transform which will remove the response trailer.
    ```typescript
  withTransformResponseTrailerRemove(headerName: string, condition?: ResponseCondition): YarpRoute
  ```
- [withTransformResponseTrailersAllowed](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformresponsetrailersallowed.md) -- `method` -- Adds the transform which will only copy the allowed response trailers. Other transforms
    ```typescript
  withTransformResponseTrailersAllowed(allowedHeaders: string[]): YarpRoute
  ```
- [withTransforms](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransforms.md) -- `method` -- Sets the transforms for the route.
    ```typescript
  withTransforms(transforms: Dict<string,string>[]): YarpRoute
  ```
- [withTransformUseOriginalHostHeader](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformuseoriginalhostheader.md) -- `method` -- Adds the transform which will copy the incoming request Host header to the proxy request.
    ```typescript
  withTransformUseOriginalHostHeader(useOriginal?: boolean): YarpRoute
  ```
- [withTransformXForwarded](/reference/api/typescript/aspire.hosting.yarp/yarproute/withtransformxforwarded.md) -- `method` -- Adds the transform which will add X-Forwarded-* headers.
    ```typescript
  withTransformXForwarded(headerPrefix?: string, xDefault?: ForwardedTransformActions, xFor?: ForwardedTransformActions, xHost?: ForwardedTransformActions, xProto?: ForwardedTransformActions, xPrefix?: ForwardedTransformActions): YarpRoute
  ```
