-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
is it possible to get the registered path? #344
Comments
I am also looking for this feature 😃 I'm using prometheus to instrument my code and I'd like to use each endpoint path as label for each of my metrics, but right now, for paths using url params I get a different path for every id that I use, which is wrong because I end up with |
I came up with a quick hack. Inside your handler, you can iterate over
And you can do the same with Not the most elegant solution but it gets the job done. Hope it helps. |
This functionality was made available in master (but not yet released) https://pkg.go.dev/github.com/julienschmidt/httprouter@master#Router.SaveMatchedRoutePath router.SaveMatchedRoutePath=true
// in request
registeredPath := ps.MatchedRoutePath() |
@julienschmidt any chance to have a new tagged release for all commits since 2019? |
@julienschmidt Sorry for the ping, but it would be amazing if you could include this in a versioned release 🙏 |
Wouldn't this fail, if a value matches a fixed path element (e.g. pattern: |
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
@julienschmidt Any plans to incorporate this into a versioned release any time soon? This would be a very helpful feature. |
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
@letmestudy I hope you're enjoying your (extended) vacation! |
I'm about to use httprouter in a http api gateway, and use httprouter to match path.
i do not need a handle function, so i register paths with an empty handler:
then use LookUp method to match path
the LookUp method only returns handler, params and tsr currently.
what i need is the matched path /user/:user_id/basic to get the upstream server which is related to the path.
The text was updated successfully, but these errors were encountered: