From 69f21d5b02047308e53105b72285d23c30d3490a Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 4 Feb 2026 01:19:26 +0800 Subject: [PATCH] :bug: Fix gateway --- DysonNetwork.Gateway/Health/GatewayConstant.cs | 3 ++- DysonNetwork.Gateway/Program.cs | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/DysonNetwork.Gateway/Health/GatewayConstant.cs b/DysonNetwork.Gateway/Health/GatewayConstant.cs index 8cb74855..e3f8ff50 100644 --- a/DysonNetwork.Gateway/Health/GatewayConstant.cs +++ b/DysonNetwork.Gateway/Health/GatewayConstant.cs @@ -12,7 +12,8 @@ public abstract class GatewayConstant "develop", "insight", "zone", - "messager" + "messager", + "wallet" ]; // Default core service names used when no configuration is provided diff --git a/DysonNetwork.Gateway/Program.cs b/DysonNetwork.Gateway/Program.cs index c82314a6..970460f0 100644 --- a/DysonNetwork.Gateway/Program.cs +++ b/DysonNetwork.Gateway/Program.cs @@ -20,8 +20,15 @@ builder.Services.AddSingleton(); builder.Services.AddHostedService(); // Add configuration options for gateway endpoints -builder.Services.Configure( - builder.Configuration.GetSection(DysonNetwork.Gateway.Configuration.GatewayEndpointsOptions.SectionName)); +builder.Services.Configure( + 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() ?? 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>().Value; -GatewayConstant.InitializeFromConfiguration(gatewayEndpointsOptions); - // Reinitialize the readiness store with configured service names var readinessStore = app.Services.GetRequiredService(); readinessStore.ReinitializeServices(GatewayConstant.ServiceNames);