refactor: eliminate duplicate extractArgs closures in proxy/router.go#7210
Conversation
Add prArgs, issueArgs helpers and emptyExtractArgs, repoArgsExtractor shared closure variables. Update all 23 affected route entries to use the new helpers, removing ~40 lines of repeated boilerplate. Closes #7191
There was a problem hiding this comment.
Pull request overview
This PR refactors internal/proxy/router.go to remove repeated extractArgs anonymous functions across many REST route entries by introducing shared helper functions/closures for common argument maps.
Changes:
- Added
prArgs(...)andissueArgs(...)helpers to centralize construction of common PR/issue argument maps. - Introduced shared
extractArgsimplementations for “no args” routes and “owner/repo only” routes, and reused them across route entries. - Updated affected routes to reference these helpers instead of repeating inline map literals/closures.
Show a summary per file
| File | Description |
|---|---|
| internal/proxy/router.go | Deduplicates repeated extractArgs closures/map literals via shared helpers and shared extractors in the route table. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
Merged |
internal/proxy/router.gohad ~40 lines of repeatedextractArgsboilerplate across 23 route entries — identical anonymous functions wrapping the same map literals.Changes
Adds four shared helpers alongside the existing
repoArgsfunction:prArgs(owner, repo, pullNumber, method string)— builds PR args map; replaces 4 inline literalsissueArgs(owner, repo, issueNumber string, method ...string)— builds issue args map with optional method; replaces 3 inline literalsemptyExtractArgs— shared closure returningmap[string]interface{}{}; replaces 6 identical anonymous funcsrepoArgsExtractor— shared closure returningrepoArgs(m[1], m[2]); replaces 10 identical anonymous func wrappersRoutes that previously needed a wrapper closure just to call
repoArgsor return an empty map now reference the shared variable directly:Routes that build richer maps (PR, issue) now delegate to typed helpers instead of open-coded map literals: