Skip to content

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

Open
thaJeztah wants to merge 1 commit into
rootless-containers:masterfrom
thaJeztah:rm_gorilla_mux
Open

thaJeztah wants to merge 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.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
thaJeztah marked this pull request as ready for review October 12, 2026 18:10
Comment thread pkg/api/router/router.go
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()

@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
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.
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