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

new field and getter in Request for matchedRoute #1049

Merged
merged 3 commits into from
Mar 14, 2019
Merged

Conversation

robax
Copy link
Contributor

@robax robax commented Aug 30, 2018

PR for #1048 ping @perwendel

@robax
Copy link
Contributor Author

robax commented Sep 11, 2018

@perwendel @tipsy @jakaarl @joatmon @M-Razavi Have any of you had a chance to look at this? I would greatly appreciate it. :)

@tipsy
Copy link
Contributor

tipsy commented Sep 11, 2018

Looks good to me.

@perwendel
Copy link
Owner

perwendel commented Sep 14, 2018

@robax, @tipsy
I've had a quick look. There are a few things I'm unsure of.

First of all the method has not been implemented in RequestWrapper which makes this always return null in any route or filter.

The matchedRouteUri field in Request is not updated in changeMatch which is invoked from a couple of classes AfterFilters, BeforeFilters, AfterAfterFilters. There seems to be a discrepancy in functionality here. E.g. take this code:

        get("/hello", (request, response) -> "hello: " + request.matchedRouteUri());
        get("/users/:u", (q, a) -> "user: " + q.matchedRouteUri());

        after((q, a) -> {
            System.out.println("after: " + q.matchedRouteUri());
        });

the sysout in the after filter will say:

localhost:4567/hello -> /hello
localhost:4567/users/per -> /users/:u
localhost:4567/notmatched -> +/*paths

which is unambiguous. In the first two cases it's value is based on matching of prior routes whereas in the latter case it's the matching of the filter itself.

@tipsy
Copy link
Contributor

tipsy commented Sep 14, 2018

Seems like I didn't read this as well as I should have. I think the functionality is good, but it looks like the implementation needs some work.

@perwendel I don't see the problem with the output in your example though. In each case it prints the path that was used to match the route/filter. You could return early in a before, in which case there won't be any matching route.

Maybe matcherPath() would be a better name than matchedRouteUri() ?

@robax
Copy link
Contributor Author

robax commented Sep 14, 2018

Thanks for the thorough responses guys!

I added a method matchedRouteUri() in the RequestWrapper class and I'm now updating the matched route in the changeMatch() method. I'm also happy to change the method name as per @tipsy.

I don't see the problem with your example @perwendel. Does updating the route in changeMatch() fix your concern? Or can you further illustrate the issue?

@robax
Copy link
Contributor Author

robax commented Oct 3, 2018

Would you guys be able to take another peek at this please? @perwendel @tipsy

@tipsy
Copy link
Contributor

tipsy commented Oct 4, 2018

@robax Per is away for some time. It looks fine to me, but it would be good if you could include an integration test where you call it in a filter too.

@robax
Copy link
Contributor Author

robax commented Oct 5, 2018

Good recommendation @tipsy ! I added the integration tests and I'll wait until @perwendel gets back.

@jon-ruckwood
Copy link

This feature would be really useful for us. I was wondering if it is any closer to being accepted?

@robax
Copy link
Contributor Author

robax commented Jan 17, 2019

I pinged @perwendel on twitter (https://twitter.com/perwendel/status/1073127244988600321) a little over a month ago and he said he was close to reviewing PR's. I hope we can merge this in soon as it is a tiny change and one that would help us quite a bit aswell!

@robax
Copy link
Contributor Author

robax commented Mar 14, 2019

@tipsy Sorry to keep pinging you on this, but you seem to be the only active maintainer. Would you be able to merge this PR? I pinged @perwendel again on Twitter a month ago and haven't received a response.

@tipsy
Copy link
Contributor

tipsy commented Mar 14, 2019

Sure, this shouldn't be too controversial to merge.

@tipsy tipsy merged commit 9aebf4a into perwendel:master Mar 14, 2019
@jon-ruckwood
Copy link

Is there any timeframe for when this change will appear in a released version?

@jon-ruckwood jon-ruckwood mentioned this pull request Mar 22, 2019
@perwendel
Copy link
Owner

@robax The functionality of this is good. However, I'm not sure about the name matchedRouteUri, as @tipsy commented previously. Maybe matchedRoutePath or just matchedPath is better. I'm unsure.

@jon-ruckwood the plan is to release 2.9.0 this week.

@perwendel
Copy link
Owner

If no other input I will change to matchedPath before releasing 2.9.0. That goes best with the current nomenclature that a route is made up from a verb and a path.

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

Successfully merging this pull request may close these issues.

4 participants