-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add matchedRoutePath to Request #1126
Conversation
… handled the request reguardless of filters.
…ring of Request methods. Add test showing expected all paths filter behaviour.
The naming of this field and thus the getter is up for debate. I had toyed with using an original prefix but decided it didn't make sense. Arguably this could be |
Hmm, I've reviewed this quickly and I fail to see how this new method would return anything different the the already existing |
I've checked some more and concluded that this is just duplicate functionality of |
Hey there, glad to get the review! Initially I thought The problem with The following snippet shows the difference adapted from one of the new tests added:
This fails because the last assertion for the This behaviour is further reinforced by the tests like this one. The test ensures the spark/src/test/java/spark/RequestTest.java Line 143 in 10ddf62
This situation was pointed out in the original implementation of Happy to discuss more cases and why I ended up requiring this feature. I've been using it for quite some time now. |
We're in the processing of adding request tracing to all of our java systems, all of which are using Spark as their web framework. To do so we implemented global
before
and anafterAfter
filter which records information about the request and the response and sends it off to our tracing implementation. After the first version was released we noticed an improvement could be made by sanitizing paths params and using the route parameter key as the cleaned version.This technique was noted in #959 and #1048 with #1049 appearing to close both those issues.
The problem for our use case occurs because we implement automatic tracing of requests as
ALL_PATHS
filters. This becomes a problem becausematchedUri()
in a globalafter
filter will return all paths and not that actual matched route path (#1049 (comment)).The proposal in this PR is to introduce a new field called
matchedRoutePath
with a getter and setter. The setter records the path during the route execution so it is available in the getter forafter
andafterAfter
filters to use.