-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
Failing test for 404 when no GET root #113
Conversation
@lasseebert Hey, thanks for catching this problem. Does this failing test reveal the intention of writing a fix? 😉 |
@jodosha, yes it does ;) Was just checking in before writing any code. I will try to make a fix for this bug. |
Findings so far:
|
@lasseebert Thank you for taking the time to check this. Please remember that we can "fix" |
It looks like the current behavior when the request doesn't match a route can be summarized as:
Some tests I tried, that demonstrate this:
I'm wondering if this is actually intended behavior in What should Hanami be treating as 404s vs 405s? The current behavior gives a mixture of 404s and 405s for different methods on a RESTful resource, which seem a little confusing. Maybe 405 could be used strictly for when it's a route for the request path, but not the request method. Or, going the way of Rails and Sinatra, all route misses could be 404s. |
@bruz Yes. I agree. To recap: missing paths should return 404. Existing paths called with wrong HTTP verb should return 405. |
I'm glad we all agree :) Sorry for not participating more in this issue. The issue was originally found on a customer's project, and that project doesn't have the problem anymore. So I couldn't really use their time to fix the bug. Will see if I get some spare-time to look into it anytime soon :) |
@AlfonsoUceda Any news on this? |
@jodosha sorry I didn't take a look from when I assigned it |
@lasseebert thanks for this PR but I'm going to close it, our idea is to change http_router dependency by another maintained router or build our own router. The problem is that http_router is a mess, it's very difficult to debug because it generates a lot of code with metaprogramming. I debugged this problem and the router generates allowed methods for one path when you make a request and because how it works, we have those problems. |
I have an app where there is no
GET /
route defined, but aPOST /
is defined (and several other GET routes).This seems to mess up response status code for GET requests that does not resolve to a route.
See failing spec, which fails with message
Is this behaviour somehow by design?