refactor: consolidate method-dispatch boilerplate in operation/* #8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Many tools in
operation/*follow the same shape: a single*_read/*_writetool with amethodenum that fans out to ~5–10 sub-handlers. The fan-out is reimplemented per module — each does its own switch, its own param extraction, its own error wrapping. Adding a new common behavior (e.g. consistent logging, pagination caps, the%wsweep) requires editing the same shape dozens of times.Examples:
operation/issue/issue.go,operation/label/label.go,operation/milestone/milestone.go,operation/repo/*,operation/pull/pull.go.Suggested direction
Introduce a small dispatcher in
pkg/tool:Each module registers a
map[string]MethodHandlerinstead of a hand-rolled switch. Cross-cutting concerns (logging, validation, error wrapping) live in the dispatcher, applied once.