go-proxy ls-route now query api server first, then fallback to read from config file

This commit is contained in:
yusing
2024-09-30 15:56:03 +08:00
parent b38d7595a7
commit 9065d990e5
4 changed files with 28 additions and 9 deletions

View File

@@ -91,7 +91,14 @@ func main() {
printJSON(cfg.Value())
return
case common.CommandListRoutes:
printJSON(cfg.RoutesByAlias())
routes, err := apiUtils.ListRoutes()
if err.HasError() {
log.Printf("failed to connect to api server: %s", err)
log.Printf("falling back to config file")
printJSON(cfg.RoutesByAlias())
} else {
printJSON(routes)
}
return
case common.CommandDebugListEntries:
printJSON(cfg.DumpEntries())