Skip to content

feat(mux): support http.Request.PathValue in Go 1.22#901

Merged
pkieltyka merged 1 commit intogo-chi:masterfrom
angelofallars:path-value
Feb 17, 2024
Merged

feat(mux): support http.Request.PathValue in Go 1.22#901
pkieltyka merged 1 commit intogo-chi:masterfrom
angelofallars:path-value

Conversation

@angelofallars
Copy link
Contributor

Resolves #873

Adds support for getting path values with http.Request.PathValue.

In Go versions earlier than 1.22 that don't have that method this shouldn't break them due to conditional compilation.

http.Request.PathValue will act as an alias for chi.URLParam.

The only syntax in common with 1.22 pattern matching seems to be single-segment matches like /b/{bucket}. Other 1.22 features like remaining segment matches (/files/{path...}) and matching trailing slashes (/exact/match/{$}) are not yet supported. Since they are more complicated and overlap with already-existing Chi functionality, they should be addressed in a separate discussion/PR.

@angelofallars angelofallars changed the title feat(mux): Support http.Request.PathValue in Go 1.22 feat(mux): support http.Request.PathValue in Go 1.22 Feb 12, 2024
@pkieltyka pkieltyka merged commit fd0ff0e into go-chi:master Feb 17, 2024
@pkieltyka
Copy link
Member

thanks again @angelofallars :)

@angelofallars
Copy link
Contributor Author

@pkieltyka You're welcome! :)

Gusted added a commit to Gusted/chi that referenced this pull request Mar 3, 2025
Similar to go-chi#901

Adds support to get the pattern that was used by Chi to match the route,
without needing to call the Chi context.
VojtechVitek pushed a commit that referenced this pull request Aug 26, 2025
Similar to #901

Adds support to get the pattern that was used by Chi to match the route,
without needing to call the Chi context.
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.

Feature: on Go 1.22, fill (*http.Request).PathValue with URLParam data

2 participants