Browse Source

Use YARP native config

davidfowl/common-services
David Fowler 1 year ago
committed by Reuben Bond
parent
commit
64a2d69e92
2 changed files with 19 additions and 26 deletions
  1. +1
    -8
      src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs
  2. +18
    -18
      src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json

+ 1
- 8
src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs View File

@ -4,14 +4,7 @@ internal static class Extensions
{
public static IServiceCollection AddReverseProxy(this IServiceCollection services, IConfiguration configuration)
{
services.AddReverseProxy().LoadFromConfig(configuration.GetRequiredSection("ReverseProxy"))
.AddTransforms(builder =>
{
if (builder.Route?.Metadata?["prefix"] is string prefix)
{
builder.AddPathRemovePrefix($"/{prefix}");
}
});
services.AddReverseProxy().LoadFromConfig(configuration.GetRequiredSection("ReverseProxy"));
return services;
}


+ 18
- 18
src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json View File

@ -35,54 +35,54 @@
"Match": {
"Path": "c/{**catch-all}"
},
"Metadata": {
"prefix": "c"
}
"Transforms": [
{ "PathRemovePrefix": "/c" }
]
},
"c-long": {
"ClusterId": "catalog",
"Match": {
"Path": "catalog-api/{**catch-all}"
},
"Metadata": {
"prefix": "catalog-api"
}
"Transforms": [
{ "PathRemovePrefix": "/catalog-api" }
]
},
"b-short": {
"ClusterId": "basket",
"Match": {
"Path": "b/{**catch-all}"
},
"Metadata": {
"prefix": "b"
}
"Transforms": [
{ "PathRemovePrefix": "/b" }
]
},
"b-long": {
"ClusterId": "basket",
"Match": {
"Path": "basket-api/{**catch-all}"
},
"Metadata": {
"prefix": "basket-api"
}
"Transforms": [
{ "PathRemovePrefix": "/basket-api" }
]
},
"o-short": {
"ClusterId": "orders",
"Match": {
"Path": "o/{**catch-all}"
},
"Metadata": {
"prefix": "o"
}
"Transforms": [
{ "PathRemovePrefix": "/o" }
]
},
"o-long": {
"ClusterId": "orders",
"Match": {
"Path": "ordering-api/{**catch-all}"
},
"Metadata": {
"prefix": "ordering-api"
}
"Transforms": [
{ "PathRemovePrefix": "/ordering-api" }
]
},
"h-long": {
"ClusterId": "signalr",


Loading…
Cancel
Save