-
-
Notifications
You must be signed in to change notification settings - Fork 988
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
Fix Mux.Find
not correctly handling nested routes
#954
Fix Mux.Find
not correctly handling nested routes
#954
Conversation
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.
@dils2k can you please give this a try and report back?
|
||
if node != nil { | ||
if node.subroutes == nil { | ||
e := node.endpoints[m] |
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.
can this every panic?
would it be safer to e, ok := node.endpoints[m]
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.
@VojtechVitek No because mx.tree.FindRoute(rctx, m, path)
will return nil
if there is not a matching endpoint for the method.
Yup! It works. |
r.Route("/yo", func(r Router) { | ||
r.Get("/sup", func(w http.ResponseWriter, r *http.Request) { | ||
w.Write([]byte("sup")) | ||
}) | ||
}) |
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.
👍
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
Thank you :)
Follow-up to #872 to fix
Mux.Find
not correctly handling nested routes (See #872 (comment)).