🐛 Fix gateway

This commit is contained in:
2026-02-04 01:19:26 +08:00
parent 30c87629ad
commit 69f21d5b02
2 changed files with 11 additions and 9 deletions

View File

@@ -12,7 +12,8 @@ public abstract class GatewayConstant
"develop",
"insight",
"zone",
"messager"
"messager",
"wallet"
];
// Default core service names used when no configuration is provided

View File

@@ -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);