Skip to content
DocsTry Aspire
DocsTry

YarpRouteExtensions Methods

ClassMethods11 members
Provides extension methods for configuring a YARP destination
WithMatch(YarpRoute, RouteMatch)Section titled WithMatch(YarpRoute, RouteMatch)extensionYarpRoute
Set the parameters used to match requests.
public static class YarpRouteExtensions
{
public static YarpRoute WithMatch(
this YarpRoute route,
RouteMatch match)
{
// ...
}
}
matchRouteMatch
This overload is not available in polyglot app hosts. Use the DTO-based overload or the specific match helper methods instead.
WithMatchHeaders(YarpRoute, RouteHeader[])Section titled WithMatchHeaders(YarpRoute, RouteHeader[])extensionYarpRoute
Only match requests that contain all of these headers.
public static class YarpRouteExtensions
{
public static YarpRoute WithMatchHeaders(
this YarpRoute route,
params RouteHeader[] headers)
{
// ...
}
}
headersRouteHeader[]
This overload is not available in polyglot app hosts. Use the DTO-based overload instead.
WithMatchHosts(YarpRoute, string[])Section titled WithMatchHosts(YarpRoute, string[])extensionYarpRoute
Only match requests with the given Host header. Supports wildcards and ports. For unicode host names, do not use punycode.
public static class YarpRouteExtensions
{
public static YarpRoute WithMatchHosts(
this YarpRoute route,
params string[] hosts)
{
// ...
}
}
hostsstring[]
WithMatchMethods(YarpRoute, string[])Section titled WithMatchMethods(YarpRoute, string[])extensionYarpRoute
Only match requests that use these optional HTTP methods. E.g. GET, POST.
public static class YarpRouteExtensions
{
public static YarpRoute WithMatchMethods(
this YarpRoute route,
params string[] methods)
{
// ...
}
}
methodsstring[]
WithMatchPath(YarpRoute, string)Section titled WithMatchPath(YarpRoute, string)extensionYarpRoute
Only match requests with the given Path pattern.
public static class YarpRouteExtensions
{
public static YarpRoute WithMatchPath(
this YarpRoute route,
string path)
{
// ...
}
}
pathstring
WithMatchRouteQueryParameter(YarpRoute, RouteQueryParameter[])Section titled WithMatchRouteQueryParameter(YarpRoute, RouteQueryParameter[])extensionYarpRoute
Only match requests that contain all of these query parameters.
public static class YarpRouteExtensions
{
public static YarpRoute WithMatchRouteQueryParameter(
this YarpRoute route,
params RouteQueryParameter[] queryParameters)
{
// ...
}
}
queryParametersRouteQueryParameter[]
This overload is not available in polyglot app hosts. Use the DTO-based overload instead.
WithMaxRequestBodySize(YarpRoute, long)Section titled WithMaxRequestBodySize(YarpRoute, long)extensionYarpRoute
Set the MaxRequestBodySize for the destination
public static class YarpRouteExtensions
{
public static YarpRoute WithMaxRequestBodySize(
this YarpRoute route,
long maxRequestBodySize)
{
// ...
}
}
maxRequestBodySizelong
WithMetadata(YarpRoute, IReadOnlyDictionary<string, string>)Section titled WithMetadata(YarpRoute, IReadOnlyDictionary<string, string>)extensionYarpRoute
Set the Metadata of the destination
public static class YarpRouteExtensions
{
public static YarpRoute WithMetadata(
this YarpRoute route,
IReadOnlyDictionary<string, string>? metadata)
{
// ...
}
}
metadataIReadOnlyDictionary<string, string>
WithOrder(YarpRoute, int?)Section titled WithOrder(YarpRoute, int?)extensionYarpRoute
Set the order for the destination
public static class YarpRouteExtensions
{
public static YarpRoute WithOrder(
this YarpRoute route,
int? order)
{
// ...
}
}
orderint?
WithTransform(YarpRoute, Action<IDictionary<string, string>>)Section titled WithTransform(YarpRoute, Action<IDictionary<string, string>>)extensionYarpRoute
Add a new transform to the destination
public static class YarpRouteExtensions
{
public static YarpRoute WithTransform(
this YarpRoute route,
Action<IDictionary<string, string>> createTransform)
{
// ...
}
}
createTransformAction<IDictionary<string, string>>
This method is not available in polyglot app hosts. Use YarpRouteExtensions.WithTransforms or the transform-specific helpers instead.
WithTransforms(YarpRoute, IReadOnlyList<IReadOnlyDictionary<string, string>>)Section titled WithTransforms(YarpRoute, IReadOnlyList<IReadOnlyDictionary<string, string>>)extensionYarpRoute
Set the Transforms of the destination
public static class YarpRouteExtensions
{
public static YarpRoute WithTransforms(
this YarpRoute route,
IReadOnlyList<IReadOnlyDictionary<string, string>>? transforms)
{
// ...
}
}
transformsIReadOnlyList<IReadOnlyDictionary<string, string>>