-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Allow different param names in different methods with same path scheme #2209
Conversation
@aldas could you run tests again? Added small fix |
I forgot about middleware tests. Fixed |
Signed-off-by: ortyomka <iurin.art@gmail.com>
ec17a4a
to
3e45d2a
Compare
Found a quicker and easier way for the new structure. In old - original
original vs current
cc @aldas, ready for review |
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.
I do not understand why this new struct methodContext
is necessary in this PR context? I do not see it adding any functional or performance value. Changing things from HandlerFunc
to pointer seems unnecessary as function types are nillable.
Agree, I will add functionality |
Signed-off-by: ortyomka <iurin.art@gmail.com>
Added functionality, to store different paths and parameters in different methods Done @aldas |
@aldas , if you have time, please review PR |
router.go
Outdated
@@ -13,14 +13,17 @@ type ( | |||
routes map[string]*Route | |||
echo *Echo | |||
} | |||
methodContext struct { |
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.
I do not think that context
describes this struct correctly. In world of http servers and Echo context is something more temporary. I have used routeMethod
in v5
for similar struct but in v5
methodHandler
struct is also renamed to routeMethods
.
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.
Renamed to routeMethod
Add paramsCount in each node for perfomance Signed-off-by: ortyomka <iurin.art@gmail.com>
@aldas I have fixed comments, could you take a look? |
Codecov Report
@@ Coverage Diff @@
## master #2209 +/- ##
==========================================
+ Coverage 92.26% 92.29% +0.02%
==========================================
Files 37 37
Lines 3090 3102 +12
==========================================
+ Hits 2851 2863 +12
Misses 150 150
Partials 89 89
Continue to review full report at Codecov.
|
router.go
Outdated
} else { | ||
// use previous match as basis. although we have no matching handler we have path match. | ||
// so we can send http.StatusMethodNotAllowed (405) instead of http.StatusNotFound (404) | ||
currentNode = previousBestMatchNode | ||
|
||
ctx.path = path |
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.
See comment below. This is incorrect as path
must be path of the route not path of the request.
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.
Fixed
Signed-off-by: ortyomka <iurin.art@gmail.com>
Signed-off-by: ortyomka <iurin.art@gmail.com>
I would like to finish this PR by Tuesday(12.07) inclusive. If your schedule allows it, I'm willing to fix comments ASAP. CC @aldas |
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 this PR is good enough for current state. Params for 405 etc are things we/I can address later when there is a decision what the behavior should be. These questions are not necessary to be solved with this change.
Thank you for PR.
Relates to issues #1726 and #2201
Parameters and paths are now separated by methods within the same node.
Add new method Context, which store path, parameters, and handler.
Add test from #1726.
CC @aldas