🐛 Fix gateway
This commit is contained in:
@@ -20,8 +20,15 @@ builder.Services.AddSingleton<GatewayReadinessStore>();
|
||||
builder.Services.AddHostedService<GatewayHealthAggregator>();
|
||||
|
||||
// Add configuration options for gateway endpoints
|
||||
builder.Services.Configure<DysonNetwork.Gateway.Configuration.GatewayEndpointsOptions>(
|
||||
builder.Configuration.GetSection(DysonNetwork.Gateway.Configuration.GatewayEndpointsOptions.SectionName));
|
||||
builder.Services.Configure<GatewayEndpointsOptions>(
|
||||
builder.Configuration.GetSection(GatewayEndpointsOptions.SectionName));
|
||||
|
||||
// Initialize GatewayConstant with configuration values early
|
||||
// This must happen before routes are defined since they use GatewayConstant.ServiceNames
|
||||
var gatewayEndpointsOptions = builder.Configuration
|
||||
.GetSection(GatewayEndpointsOptions.SectionName)
|
||||
.Get<GatewayEndpointsOptions>() ?? new GatewayEndpointsOptions();
|
||||
GatewayConstant.InitializeFromConfiguration(gatewayEndpointsOptions);
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
@@ -69,7 +76,6 @@ builder.Services.AddRateLimiter(options =>
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
var specialRoutes = new[]
|
||||
{
|
||||
new RouteConfig
|
||||
@@ -176,11 +182,6 @@ builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Initialize GatewayConstant with configuration values
|
||||
var gatewayEndpointsOptions = app.Services
|
||||
.GetRequiredService<IOptions<GatewayEndpointsOptions>>().Value;
|
||||
GatewayConstant.InitializeFromConfiguration(gatewayEndpointsOptions);
|
||||
|
||||
// Reinitialize the readiness store with configured service names
|
||||
var readinessStore = app.Services.GetRequiredService<GatewayReadinessStore>();
|
||||
readinessStore.ReinitializeServices(GatewayConstant.ServiceNames);
|
||||
|
||||
Reference in New Issue
Block a user