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) |     public static IServiceCollection AddReverseProxy(this IServiceCollection services, IConfiguration configuration) | ||||||
|     { |     { | ||||||
|         // REVIEW: This should come from configuration |         // REVIEW: We could load the routes and clusters from configuration instead of code | ||||||
|         var s = new (string, string, string, bool)[] |         // 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), |             s.Add((c["0"], c["1"], c["2"], c.GetValue("3", false))); | ||||||
|             ("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) |  | ||||||
|         }; |  | ||||||
| 
 | 
 | ||||||
|         var routes = new List<RouteConfig>(); |         var routes = new List<RouteConfig>(); | ||||||
|         var clusters = new Dictionary<string, ClusterConfig>(); |         var clusters = new Dictionary<string, ClusterConfig>(); | ||||||
|  | |||||||
| @ -27,6 +27,18 @@ | |||||||
|       "webshoppingagg": "Shopping Aggregator for Web Clients" |       "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": { |   "Urls": { | ||||||
|     "Basket": "http://localhost:5221", |     "Basket": "http://localhost:5221", | ||||||
|     "Catalog": "http://localhost:5222", |     "Catalog": "http://localhost:5222", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user