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

MatchErr is set to ErrNotFound if NotFoundHandler is used #311

Merged
merged 3 commits into from
Nov 5, 2017
Merged

MatchErr is set to ErrNotFound if NotFoundHandler is used #311

merged 3 commits into from
Nov 5, 2017

Conversation

nadiamoe
Copy link
Contributor

@nadiamoe nadiamoe commented Nov 3, 2017

As discussed in #293, it should be useful if RouteMatch.MatchErr were set to an error if no match is found, even if some subrouters have a custom NotFoundHandler.

Copy link
Contributor

@elithrar elithrar left a comment

Choose a reason for hiding this comment

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

Thanks for this!

mux_test.go Outdated
matched := r.Match(req, match)

if matched {
t.Error("Subrouter should not have matched that")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add some context - ”subrouter should not have matched: got %v”, route” to aid debugging.

mux_test.go Outdated
matched = s.Match(req, match)
// Now we should get a match
if !matched {
t.Error("Subrouter should have matched that")
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too.

mux_test.go Outdated

// Now we should get a match
if !matched {
t.Error("Subrouter should have matched that")
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too.

@nadiamoe
Copy link
Contributor Author

nadiamoe commented Nov 3, 2017

I've added the matching route where none is expected but one is got. I've also moved the last two test cases above the private functions, which I think is more appropriate.

The go fmt issue with travis is bugging me a bit, but afaik it's not my fault. It appeared when I merged upstream :/

@elithrar
Copy link
Contributor

elithrar commented Nov 4, 2017

Thanks for this. Let me see why gofmt is failing [only] on tip.

@elithrar elithrar self-assigned this Nov 4, 2017
@elithrar
Copy link
Contributor

elithrar commented Nov 4, 2017 via email

Copy link
Contributor

@elithrar elithrar left a comment

Choose a reason for hiding this comment

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

@kisielk for a second approval.

@elithrar elithrar requested a review from kisielk November 4, 2017 23:56
route.go Outdated
@@ -72,7 +72,11 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
return false
}

match.MatchErr = nil
if match.MatchErr == ErrMethodMismatch {
// We found a non-mismatching route, clear MatchErr
Copy link
Contributor

Choose a reason for hiding this comment

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

non-mismatching is a bit of a double negative :) how about just "matching" so it's less confusing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I used that wording to make clear that the ErrMethodMismatch found on the previous iteration no longer applies. But I guess I can reword it a bit.

I'll do it tomorrow tho, its 2AM here and I'm quite asleep.

@kisielk
Copy link
Contributor

kisielk commented Nov 5, 2017

LGTM other than comment

@kisielk
Copy link
Contributor

kisielk commented Nov 5, 2017

Thanks! I don't mean to be too nitpicky, but the code base is already pretty hard to follow so any little bit helps.

@kisielk kisielk merged commit 7f08801 into gorilla:master Nov 5, 2017
@nadiamoe
Copy link
Contributor Author

nadiamoe commented Nov 5, 2017

@kisielk No prob! I'm not a native speaker, so I can make some grammar mistakes here and there. Also, I'd do the same on projects I mantain :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants