Use YARP native config
This commit is contained in:
parent
69476a3175
commit
64a2d69e92
@ -4,14 +4,7 @@ internal static class Extensions
|
|||||||
{
|
{
|
||||||
public static IServiceCollection AddReverseProxy(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddReverseProxy(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.AddReverseProxy().LoadFromConfig(configuration.GetRequiredSection("ReverseProxy"))
|
services.AddReverseProxy().LoadFromConfig(configuration.GetRequiredSection("ReverseProxy"));
|
||||||
.AddTransforms(builder =>
|
|
||||||
{
|
|
||||||
if (builder.Route?.Metadata?["prefix"] is string prefix)
|
|
||||||
{
|
|
||||||
builder.AddPathRemovePrefix($"/{prefix}");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
@ -35,54 +35,54 @@
|
|||||||
"Match": {
|
"Match": {
|
||||||
"Path": "c/{**catch-all}"
|
"Path": "c/{**catch-all}"
|
||||||
},
|
},
|
||||||
"Metadata": {
|
"Transforms": [
|
||||||
"prefix": "c"
|
{ "PathRemovePrefix": "/c" }
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"c-long": {
|
"c-long": {
|
||||||
"ClusterId": "catalog",
|
"ClusterId": "catalog",
|
||||||
"Match": {
|
"Match": {
|
||||||
"Path": "catalog-api/{**catch-all}"
|
"Path": "catalog-api/{**catch-all}"
|
||||||
},
|
},
|
||||||
"Metadata": {
|
"Transforms": [
|
||||||
"prefix": "catalog-api"
|
{ "PathRemovePrefix": "/catalog-api" }
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"b-short": {
|
"b-short": {
|
||||||
"ClusterId": "basket",
|
"ClusterId": "basket",
|
||||||
"Match": {
|
"Match": {
|
||||||
"Path": "b/{**catch-all}"
|
"Path": "b/{**catch-all}"
|
||||||
},
|
},
|
||||||
"Metadata": {
|
"Transforms": [
|
||||||
"prefix": "b"
|
{ "PathRemovePrefix": "/b" }
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"b-long": {
|
"b-long": {
|
||||||
"ClusterId": "basket",
|
"ClusterId": "basket",
|
||||||
"Match": {
|
"Match": {
|
||||||
"Path": "basket-api/{**catch-all}"
|
"Path": "basket-api/{**catch-all}"
|
||||||
},
|
},
|
||||||
"Metadata": {
|
"Transforms": [
|
||||||
"prefix": "basket-api"
|
{ "PathRemovePrefix": "/basket-api" }
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"o-short": {
|
"o-short": {
|
||||||
"ClusterId": "orders",
|
"ClusterId": "orders",
|
||||||
"Match": {
|
"Match": {
|
||||||
"Path": "o/{**catch-all}"
|
"Path": "o/{**catch-all}"
|
||||||
},
|
},
|
||||||
"Metadata": {
|
"Transforms": [
|
||||||
"prefix": "o"
|
{ "PathRemovePrefix": "/o" }
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"o-long": {
|
"o-long": {
|
||||||
"ClusterId": "orders",
|
"ClusterId": "orders",
|
||||||
"Match": {
|
"Match": {
|
||||||
"Path": "ordering-api/{**catch-all}"
|
"Path": "ordering-api/{**catch-all}"
|
||||||
},
|
},
|
||||||
"Metadata": {
|
"Transforms": [
|
||||||
"prefix": "ordering-api"
|
{ "PathRemovePrefix": "/ordering-api" }
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"h-long": {
|
"h-long": {
|
||||||
"ClusterId": "signalr",
|
"ClusterId": "signalr",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user