Skip to content

pkg/api: replace github.com/gorilla/mux with stdlib - #652

Merged
AkihiroSuda merged 1 commit into
rootless-containers:masterfrom
thaJeztah:rm_gorilla_mux
Oct 14, 2026
Merged

AkihiroSuda merged 1 commit into
rootless-containers:masterfrom
thaJeztah:rm_gorilla_mux

Conversation

@thaJeztah

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread pkg/parent/parent.go Outdated
// - https://github.com/rootless-containers/rootlesskit/pull/188
func createCleanupLock(sDir string) error {
//lock state dir when using /tmp/ path
// lock state dir when using /tmp/ path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be a separate commit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! Yeah, can do; didn't notice it formatted it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted it for now; I considered running gofumpt and enabling it as formatter in golangci-lint, but that resulted in various other changes, so keeping that for a follow-up.

@thaJeztah
thaJeztah marked this pull request as ready for review October 12, 2026 18:10
Comment thread pkg/api/router/router.go Outdated
func AddRoutes(r *http.ServeMux, b *Backend) {
r.HandleFunc("GET /v1/ports", b.GetPorts)
r.HandleFunc("POST /v1/ports", b.PostPort)
r.HandleFunc("DELETE /v1/ports/{$}", b.DeletePort) // Preserve the 400 response for a missing port ID instead of returning 404.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The comment string could be moved to DeletePort()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. right, so my AI was lying to me 😂 - it suggested adding this to preserve the old behavior, but looks like the old behavior (b.DeletePort checking for a missing id) already may have been dead code, so would already produce a 404.

I'll remove the extra route, and the empty ID check.

@AkihiroSuda AkihiroSuda added this to the v3.3.0 milestone Oct 12, 2026
@AkihiroSuda
AkihiroSuda requested a balanced review from Copilot October 13, 2026 01:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The added empty-ID route changes existing API behavior instead of preserving it.

1 open finding
What changed in this PR

Replaces Gorilla Mux with Go’s standard HTTP router for the API server.

Changes:

  • Migrates API route registration to http.ServeMux.
  • Uses Request.PathValue for port IDs.
  • Removes the Gorilla Mux dependency.
File Description
pkg/​parent/​parent.go Creates the API router with http.NewServeMux.
pkg/​api/​router/​router.go Migrates route definitions and path parameters.
go.mod Removes the direct Gorilla Mux dependency.
go.sum Removes Gorilla Mux checksums.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/api/router/router.go Outdated
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The migration is complete, compatible with the declared Go version, and preserves the existing routes.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda
AkihiroSuda merged commit 882936b into rootless-containers:master Oct 14, 2026
10 checks passed
@thaJeztah
thaJeztah deleted the rm_gorilla_mux branch October 14, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants