Browse Source

Specify routes in config

davidfowl/common-services
David Fowler 1 year ago
committed by Reuben Bond
parent
commit
758d4bbe88
2 changed files with 18 additions and 13 deletions
  1. +6
    -13
      src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs
  2. +12
    -0
      src/ApiGateways/Web.Bff.Shopping/aggregator/appsettings.json

+ 6
- 13
src/ApiGateways/Web.Bff.Shopping/aggregator/Extensions/Extensions.cs View File

@ -5,20 +5,13 @@ internal static class Extensions
{
public static IServiceCollection AddReverseProxy(this IServiceCollection services, IConfiguration configuration)
{
// REVIEW: This should come from configuration
var s = new (string, string, string, bool)[]
// REVIEW: We could load the routes and clusters from configuration instead of code
// using YARP's default schema, it's slightly more verbose but also reloable.
var s = new List<(string, string, string, bool)>();
foreach (var c in configuration.GetRequiredSection("Routes").GetChildren())
{
("c-short", "c", "catalog", true),
("c-long", "catalog-api", "catalog", true),
("b-short", "b", "basket", true),
("b-long", "basket-api", "basket", true),
("o-short", "o", "orders", true) ,
("o-long", "ordering-api", "orders", true),
("h-long", "hub/notificationhub", "signalr", false)
};
s.Add((c["0"], c["1"], c["2"], c.GetValue("3", false)));
}
var routes = new List<RouteConfig>();
var clusters = new Dictionary<string, ClusterConfig>();


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

@ -27,6 +27,18 @@
"webshoppingagg": "Shopping Aggregator for Web Clients"
}
},
"Routes": [
[ "c-short", "c", "catalog", true ],
[ "c-long", "catalog-api", "catalog", true ],
[ "b-short", "b", "basket", true ],
[ "b-long", "basket-api", "basket", true ],
[ "o-short", "o", "orders", true ],
[ "o-long", "ordering-api", "orders", true ],
[ "h-long", "hub/notificationhub", "signalr", false ]
],
"Urls": {
"Basket": "http://localhost:5221",
"Catalog": "http://localhost:5222",


Loading…
Cancel
Save