feat(surf): print the serve URL and admin status on startup

- Add surf.Router.AdminPrefix (additive): the admin mount path and true
  when BuildRouter mounted the cabana admin, false otherwise
- serve binds with net.Listen before printing, so a busy port fails
  without a misleading URL, then prints the listen address with a
  browser URL and an admin status line: the admin URL, a warning naming
  summer admin:create when backend_users is empty or missing, or
  admin: off with the steps to add an admin controller
- The administrator count is bounded by a 2 s timeout and never fails boot
- route:list ends with the same admin status line
- surf and cabana READMEs and the console and routing docs describe the output
This commit is contained in:
Jakub Zych
2026-10-08 16:36:21 +02:00
parent 4b5ed7707e
commit da21670870
10 changed files with 294 additions and 10 deletions

View File

@@ -11,7 +11,8 @@ import (
)
// RouteListCommand builds the router the same way ServeCommand does, then
// renders Routes() as a table instead of serving.
// renders Routes() as a table instead of serving, followed by the admin
// status line.
func RouteListCommand(app *backpack.App, plugins []party.Plugin) bonfire.Command {
return bonfire.Command{
Name: "route:list",
@@ -33,6 +34,11 @@ func RouteListCommand(app *backpack.App, plugins []party.Plugin) bonfire.Command
})
}
out.Table([]string{"Method", "Pattern", "Plugin", "Middleware", "Raw"}, rows)
if prefix, mounted := r.AdminPrefix(); mounted {
out.Info("admin: mounted at " + prefix)
} else {
out.Info(adminOffText)
}
return nil
},
}