Skip to content
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

Plan to Consolidate with net/http @ 1.22? #380

Open
garukun opened this issue Feb 20, 2024 · 1 comment
Open

Plan to Consolidate with net/http @ 1.22? #380

garukun opened this issue Feb 20, 2024 · 1 comment

Comments

@garukun
Copy link

garukun commented Feb 20, 2024

Go 1.22 has released Enhanced routing patterns; I wonder if there's been any thoughts phasing this library to be more compatible with stdlib, such as leveraging the http.Request object for the path params, or supporting the stdlib path param patterns, etc.

This router is already awesome. I think it would even greater if it can allow a stdlib ServeMux with path params to seamlessly transition to httprouter with a speed upgrade.

Thanks for the consideration!

@bradleypeabody
Copy link

bradleypeabody commented Aug 3, 2024

I haven't looked too closely, but it seems like updating https://pkg.go.dev/github.com/julienschmidt/httprouter#Router.Handler and https://pkg.go.dev/github.com/julienschmidt/httprouter#Router.HandlerFunc to just call https://pkg.go.dev/net/http#Request.SetPathValue in addition to the existing behavior would be the primary thing that's needed (at least to make it so path params could be used with handlers and handler functions interchangeably with this library and http.ServeMux). It could be easily guarded in a separate file with a build tag to only do this in 1.22+, for backward compatibility.

I wonder if that change and updating the readme to mention it is all that is needed? If so that's a pretty simple update. @julienschmidt would you be open to a PR on this?

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

No branches or pull requests

2 participants