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

How can I find the original route? #29

Closed
parris opened this issue Aug 4, 2015 · 5 comments
Closed

How can I find the original route? #29

parris opened this issue Aug 4, 2015 · 5 comments

Comments

@parris
Copy link

parris commented Aug 4, 2015

Let's say a request matched to /user/:id. Is there an easy way from some middleware's context to get the original route string instead of the current path.

this.url might produce /user/1234, but I'm looking for /user/:id so I can do some additional checks before some other middleware.

Thanks!

@hallas
Copy link

hallas commented Aug 4, 2015

I don't think we "stick" this anywhere, sorry

@hallas
Copy link

hallas commented Aug 4, 2015

I'm open for someone to add it in though, it could be useful

@tejasmanohar
Copy link
Member

Hmm... can't be done with route as is, but this is an interesting problem.

this.url might produce /user/1234, but I'm looking for /user/:id so I can do some additional checks before some other middleware.

@parris: I'm also open to PRs adding this but curious. What's your use case? "additional checks"? Sounds like you should pass in a compose'd route as the handler. For example,

app.use(route.get('/thing', compose([mw1, mw2, thing]))

@boertel
Copy link

boertel commented Jun 9, 2016

I would also be interested by this because it's needed by opbeat in order to track performance per request. Here is the documentation: https://opbeat.com/docs/articles/get-started-with-a-custom-nodejs-stack/#route-naming

@hfjallemark
Copy link

I believe this was addressed in #49, right?

@haoxins haoxins closed this as completed Nov 6, 2016
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

6 participants