Specify routes in config
This commit is contained in:
parent
bd745121b2
commit
758d4bbe88
@ -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>();
|
||||
|
@ -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…
x
Reference in New Issue
Block a user