Files
summercms/surf/routelist_command.go
Jakub Zych fa7e6d1870 feat(06-03): add raw groups, house middleware, and route:list
- GroupRaw plus sticky raw inheritance and registration-time house-envelope refusal via pact.HasHouseMiddleware
- Recover on raw routes writes a bare 500; non-raw keeps the house JSON body
- Router.Routes() and surf.RouteListCommand; generated main registers route:list
2026-09-19 19:55:32 +02:00

40 lines
1.0 KiB
Go

package surf
import (
"context"
"strconv"
"strings"
"git.golem15.com/golem15/summercms/backpack"
"git.golem15.com/golem15/summercms/bonfire"
"git.golem15.com/golem15/summercms/party"
)
// RouteListCommand builds the router the same way ServeCommand does, then
// renders Routes() as a table instead of serving.
func RouteListCommand(app *backpack.App, plugins []party.Plugin) bonfire.Command {
return bonfire.Command{
Name: "route:list",
Description: "List registered HTTP routes",
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
r, err := BuildRouter(app, plugins)
if err != nil {
return err
}
infos := r.Routes()
rows := make([][]string, 0, len(infos))
for _, rt := range infos {
rows = append(rows, []string{
rt.Method,
rt.Pattern,
rt.PluginID,
strings.Join(rt.Middleware, ","),
strconv.FormatBool(rt.Raw),
})
}
out.Table([]string{"Method", "Pattern", "Plugin", "Middleware", "Raw"}, rows)
return nil
},
}
}