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:
@@ -878,6 +878,8 @@ def get_gateway() -> GatewayInfo:
|
|||||||
)
|
)
|
||||||
for r in compute_routes(registry, config, remote or None)
|
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(
|
return GatewayInfo(
|
||||||
port=registry.node.gateway_port,
|
port=registry.node.gateway_port,
|
||||||
|
|||||||
@@ -137,9 +137,10 @@ def _gateway_status() -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# Each route: address → target, tagged by kind. static = files served in
|
# 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")
|
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
|
target = r.target.replace("localhost:", ":") if r.kind != "static" else r.target
|
||||||
print(f" {r.address:24} {r.kind:7} {target}")
|
print(f" {r.address:24} {r.kind:7} {target}")
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user