From e78858b7b443d742f471a1a702ea0fbcf50d3db4 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 19 Aug 2025 19:27:18 +0800 Subject: [PATCH] :zap: Speed up the gateway loopback /cgi route by letting gateway directly handle it --- .../RegistryProxyConfigProvider.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs b/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs index 2efa79c..691864a 100644 --- a/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs +++ b/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs @@ -76,6 +76,26 @@ public class RegistryProxyConfigProvider : IProxyConfigProvider, IDisposable var gatewayServiceName = _configuration["Service:Name"]; + // Add direct route for /cgi to Gateway + var gatewayCluster = new ClusterConfig + { + ClusterId = "gateway-self", + Destinations = new Dictionary + { + { "self", new DestinationConfig { Address = _configuration["Kestrel:Endpoints:Http:Url"] ?? "http://localhost:5000" } } + } + }; + clusters.Add(gatewayCluster); + + var cgiRoute = new RouteConfig + { + RouteId = "gateway-cgi-route", + ClusterId = "gateway-self", + Match = new RouteMatch { Path = "/cgi/{**catch-all}" } + }; + routes.Add(cgiRoute); + _logger.LogInformation(" Added CGI Route: /cgi/** -> Gateway"); + // Add direct routes foreach (var directRoute in directRoutes) {