🐛 Fix gateway
This commit is contained in:
@@ -12,7 +12,8 @@ public abstract class GatewayConstant
|
|||||||
"develop",
|
"develop",
|
||||||
"insight",
|
"insight",
|
||||||
"zone",
|
"zone",
|
||||||
"messager"
|
"messager",
|
||||||
|
"wallet"
|
||||||
];
|
];
|
||||||
|
|
||||||
// Default core service names used when no configuration is provided
|
// Default core service names used when no configuration is provided
|
||||||
|
|||||||
@@ -20,8 +20,15 @@ builder.Services.AddSingleton<GatewayReadinessStore>();
|
|||||||
builder.Services.AddHostedService<GatewayHealthAggregator>();
|
builder.Services.AddHostedService<GatewayHealthAggregator>();
|
||||||
|
|
||||||
// Add configuration options for gateway endpoints
|
// Add configuration options for gateway endpoints
|
||||||
builder.Services.Configure<DysonNetwork.Gateway.Configuration.GatewayEndpointsOptions>(
|
builder.Services.Configure<GatewayEndpointsOptions>(
|
||||||
builder.Configuration.GetSection(DysonNetwork.Gateway.Configuration.GatewayEndpointsOptions.SectionName));
|
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 =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
@@ -69,7 +76,6 @@ builder.Services.AddRateLimiter(options =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var specialRoutes = new[]
|
var specialRoutes = new[]
|
||||||
{
|
{
|
||||||
new RouteConfig
|
new RouteConfig
|
||||||
@@ -176,11 +182,6 @@ builder.Services.AddControllers().AddJsonOptions(options =>
|
|||||||
|
|
||||||
var app = builder.Build();
|
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
|
// Reinitialize the readiness store with configured service names
|
||||||
var readinessStore = app.Services.GetRequiredService<GatewayReadinessStore>();
|
var readinessStore = app.Services.GetRequiredService<GatewayReadinessStore>();
|
||||||
readinessStore.ReinitializeServices(GatewayConstant.ServiceNames);
|
readinessStore.ReinitializeServices(GatewayConstant.ServiceNames);
|
||||||
|
|||||||
Reference in New Issue
Block a user