Skip to content

Set the pattern to the http.Request #5697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nastik-kum
Copy link

@nastik-kum nastik-kum commented Jun 30, 2025

References to other Issues or PRs

The PR is related to Issue #3700

Have you read the Contributing Guidelines?

Yes

Brief description of what is fixed or changed

Now http.Request has the Pattern field set. httpServeMux does this and other libraries make use of this value. Now runtime.ServeMux also populates this field.

Other comments

A bit more context in the comment

Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, but this seems to me like it will break existing users, no?

@@ -532,6 +532,7 @@ type handler struct {
}

func (s *ServeMux) handleHandler(h handler, w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
r.Pattern = h.pat.GetPathPattern()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this going to overwrite the Pattern set by net/http? What about users who use r.Pattern today?

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.

2 participants