From 3100dff3a2b30d3d9be02144ff28259f191c0586 Mon Sep 17 00:00:00 2001 From: Paul Payne Date: Sun, 14 Jun 2026 22:21:25 -0700 Subject: [PATCH] gateway: alphabetize the displayed route table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort routes by address in GET /gateway and 'castle gateway status' (so the dashboard + CLI tables read alphabetically). The Caddyfile keeps its precedence-sensitive order — only the display is sorted. --- castle-api/src/castle_api/routes.py | 2 ++ cli/src/castle_cli/commands/gateway.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/castle-api/src/castle_api/routes.py b/castle-api/src/castle_api/routes.py index 010b523..d027c5b 100644 --- a/castle-api/src/castle_api/routes.py +++ b/castle-api/src/castle_api/routes.py @@ -878,6 +878,8 @@ def get_gateway() -> GatewayInfo: ) for r in compute_routes(registry, config, remote or None) ] + # Caddyfile order is precedence-sensitive; the displayed table is alphabetical. + routes.sort(key=lambda r: r.address) return GatewayInfo( port=registry.node.gateway_port, diff --git a/cli/src/castle_cli/commands/gateway.py b/cli/src/castle_cli/commands/gateway.py index 06ae0e0..c950ea0 100644 --- a/cli/src/castle_cli/commands/gateway.py +++ b/cli/src/castle_cli/commands/gateway.py @@ -137,9 +137,10 @@ def _gateway_status() -> int: return 0 # Each route: address → target, tagged by kind. static = files served in - # place; proxy/remote = reverse-proxied to a process. + # place; proxy/remote = reverse-proxied to a process. (Caddyfile order is + # precedence-sensitive; this table is alphabetical.) print(f"\n {'ADDRESS':24} {'KIND':7} TARGET") - for r in routes: + for r in sorted(routes, key=lambda r: r.address): target = r.target.replace("localhost:", ":") if r.kind != "static" else r.target print(f" {r.address:24} {r.kind:7} {target}") return 0