Store matched routes in request#2864
Conversation
|
Sorry for mentioning you @dougwilson, my mistake. |
|
@ajfranzoia ... nice! was just asked about this kind of thing at a recent node meetup. good stuff :-) |
|
Hi @ajfranzoia, thank you for your pull request! Unfortunately this pull request itself is not in a state that would be backwards-compatible with Express 4, which is the code your pull request is targeting. Express has been so API stable for such a long time, it's pretty much impossible to change any public API surface, or what seems like non-public API surface without breaking lots of production apps. Of note, it removes the The actual idea seems good, but should be made against 5.0, which does not even have route code. If you want, please transplant this pull request to see https://github.com/pillarjs/router for the discussion to open up there, where other router enthusiasts are as well :) |
|
Thanks for your reply @dougwilson. I will definitly create a PR against https://github.com/pillarjs/router during the next days. |
@dougwilson I've been working on this feature (#2501).
It allows to store every matched route in a request when travelling through nested routes. This may be useful for logging, ACL checks, etc.
So, for example, if you have your routing set like this:
A request for the URL
/foo/10/bar/baz/30will set an array of matched routes in the request object like this:Let me know if there is anything that needs to be modification, unmeaningful variable names, etc.