From 64a2d69e92c6b6f04652a1a42fe3c5643e827025 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 7 May 2023 18:18:22 -0700 Subject: [PATCH] Use YARP native config --- .../aggregator/Extensions/Extensions.cs | 9 +---- .../aggregator/appsettings.json | 36 +++++++++---------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs index 0c9aee1c2..2e7be2107 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs @@ -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; } diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json index f9f077bc5..ee2b43e35 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json @@ -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",