From dccefb0158c568ff7f64c02c9ae3fb9b7da318d7 Mon Sep 17 00:00:00 2001 From: Alexa <53471801+Alexa-RR@users.noreply.github.com> Date: Mon, 15 Jun 2026 22:04:04 +0300 Subject: [PATCH] Route browser paths to web service first --- DorkNet.Gateway/Program.cs | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/DorkNet.Gateway/Program.cs b/DorkNet.Gateway/Program.cs index 5dc1e63..d4b24f1 100644 --- a/DorkNet.Gateway/Program.cs +++ b/DorkNet.Gateway/Program.cs @@ -110,6 +110,33 @@ static IReadOnlyList BuildRoutes( "web-admin-host", [SubdomainHost("admin", apexDomain)]); + AddHostRoute( + routes, + ref order, + webGroup.ServiceName, + BaseUrlFor(services, webGroup.ServiceName), + "web-feed-host", + [SubdomainHost("feed", apexDomain)]); + + AddHostPathRoutes( + routes, + ref order, + webGroup.ServiceName, + BaseUrlFor(services, webGroup.ServiceName), + WebBrowserHosts(apexDomain), + [ + "/admin", + "/assets", + "/brand", + "/feed", + "/join", + "/p", + "/photo", + "/players", + "/rooms", + "/u", + ]); + foreach (var group in DorkNetRouteOwnership.RouteGroups.Where(group => group.ServiceName != ServiceNames.Web)) { AddHostRoute( @@ -158,6 +185,11 @@ static IReadOnlyList BuildClusters(DorkNetServiceMapOptions servi return clusters; } +static string[] WebBrowserHosts(string apexDomain) +{ + return [apexDomain, SubdomainHost("www", apexDomain)]; +} + static void AddHostRoute( List routes, ref int order, @@ -200,6 +232,28 @@ static void AddPathRoutes( } } +static void AddHostPathRoutes( + List routes, + ref int order, + string serviceName, + string baseUrl, + string[] hosts, + IEnumerable paths) +{ + if (string.IsNullOrWhiteSpace(baseUrl) || hosts.Length == 0) + { + return; + } + + foreach (var path in paths) + { + var routeId = $"{serviceName}-browser-{path.Trim('/').Replace('/', '-').Replace("{**catch-all}", "all")}"; + var exactPath = NormalizeRoutePrefix(path); + routes.Add(Route(serviceName, $"{routeId}-exact", exactPath, order++, hosts)); + routes.Add(Route(serviceName, routeId, $"{exactPath}/{{**catch-all}}", order++, hosts)); + } +} + static string BaseUrlFor(DorkNetServiceMapOptions services, string serviceName) { return serviceName switch