-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Update the code logic for latestNode in tree.go #2897
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2897 +/- ##
=======================================
Coverage 98.72% 98.73%
=======================================
Files 41 41
Lines 3066 3089 +23
=======================================
+ Hits 3027 3050 +23
Misses 27 27
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
You need to check out the Codecov and refine the unit tests. 😀 |
Already added more test for codecov test, THX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I have tried the case in #2843. But regret for that this PR cannot fix this issue. It may need other PR to fix. @Bisstocuz |
@thinkerou need your feedbacks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I think there are still some bugs. The following works: tree := &node{}
tree.addRoute("/get/:param", fakeHandler("1"))
tree.addRoute("/get/:param/foo", fakeHandler("1")) But if you change the param name of one of them, it doesn't tree := &node{}
tree.addRoute("/get/:a" fakeHandler("1"))
tree.addRoute("/get/:param/foo", fakeHandler("1"))
|
@ibraheemdev this is not a bug. It's a restriction for param route in my mind. |
I guess it's not a bug, but it's something I would expect to be supported. Would the current backtracking logic handle this? |
The current logic can only process the tree path match function, and this all after tree building progress. |
Yes, but if the backtracking logic can handle those routes, then only the insert function has to be changed. |
(cherry picked from commit 3fe9289)
(cherry picked from commit 3fe9289)
(cherry picked from commit 3fe9289)
(cherry picked from commit 3fe9289)
This PR is a new code solution for #2820 and it also solve the issues #2894 #2878
the old latestNode logic should be modified to save a list of node. Then the error match for fixed path can be roll back to the right param node and right path.
the benchmark result:
master:https://app.travis-ci.com/github/zhuxi0511/go-http-routing-benchmark/builds/239484250
this PR:https://app.travis-ci.com/github/zhuxi0511/go-http-routing-benchmark/builds/239484068
I am a new goer, so some code may not good enough. Thank you for your help and review.
This PR has 3 similar code section for roll back skippedNode. I just keep this code for simple logic to get right route guarantee. It should be optimized in next PR, Thanks!