Replace gorilla/mux with Go 1.22 stdlib ServeMux in test server#4955
Open
Replace gorilla/mux with Go 1.22 stdlib ServeMux in test server#4955
Conversation
Go 1.22 added method-based routing ("GET /items/{id}"), path wildcards
({id}), and rest wildcards ({path...}) to net/http.ServeMux, which
directly replaces the features we used gorilla/mux for. This removes the
gorilla/mux dependency from go.mod and NOTICE.
Exact (non-wildcard) paths are dispatched via a map lookup before
reaching ServeMux. This avoids a ServeMux limitation where registering
e.g. "GET /exact/path" alongside "HEAD /prefix/{path...}" panics because
Go's implicit GET→HEAD handling creates an unresolvable precedence
conflict. When an exact path is registered for one method but a request
arrives for a different method, it falls through to ServeMux where the
wildcard handler serves it.
Wildcard patterns in test stubs (test.toml) must use the same
placeholder names as the default handlers they coexist with. ServeMux
panics on structurally identical patterns with different names (e.g.
{name} vs {full_name}). Two test stubs are updated accordingly.
Co-authored-by: Isaac
Approval status: pending
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gorilla/muxdependency by switchinglibs/testserverto Go 1.22's enhancednet/http.ServeMux, which added method-based routing ("GET /items/{id}"), path wildcards ({id}), and rest wildcards ({path...}) — the same features we used gorilla for. See the Go 1.22 release notes.{path:.*}regex wildcards with stdlib{path...}rest wildcards, andmux.Vars(r)withr.PathValue().GET /exact/path, butHEADfalls through to a wildcardHEADhandler).test.tomlstubs must now use the same placeholder names as the default handlers they coexist with — ServeMux panics on structurally identical patterns with different wildcard names. Two stubs updated:{name}→{full_name}.Test plan
libs/testserver,bundle/direct/dresources,acceptance/internal)This pull request was AI-assisted by Isaac.