gateway: alphabetize the displayed route table

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.
This commit is contained in:
2026-06-14 22:21:25 -07:00
parent c40f84104d
commit 3100dff3a2
2 changed files with 5 additions and 2 deletions

View File

@@ -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,

View File

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