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

Fix Mux.Find not correctly handling nested routes #954

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

joeriddles
Copy link
Contributor

Follow-up to #872 to fix Mux.Find not correctly handling nested routes (See #872 (comment)).

Copy link
Contributor

@VojtechVitek VojtechVitek left a 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]
Copy link
Contributor

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]

Copy link
Contributor Author

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.

@dils2k
Copy link

dils2k commented Sep 25, 2024

LGTM.

@dils2k can you please give this a try and report back?

Yup! It works.

Comment on lines +1853 to +1857
r.Route("/yo", func(r Router) {
r.Get("/sup", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("sup"))
})
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you :)

@VojtechVitek VojtechVitek merged commit 6ceb498 into go-chi:master Sep 26, 2024
18 checks passed
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.

3 participants