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
actix-web returns 404 instead of 405 for unsupported verbs on resources #1256
Comments
Could you submit pr with unit test? |
Sure. You mean submit the fix as well? I'm not sure I know where the relevant code is |
Fix would good as well |
Ok, I'll try... |
@fafhrd91 I have the unit test written down, but I don't understand how to fix https://github.com/actix/actix-web/blob/9eedd010516dbc56a218e9d8c34f3a2e13c6faec/src/app_service.rs#L73 so that if any paths matched with incorrect methods it should selectively return 405... Just changing it to return 405 breaks other behaviors, and I couldn't figure out how to apply the fix you made in ffb3324 to this scenario.... |
That is because pub fn route(self, path: &str, mut route: Route) -> Self {
self.service(
Resource::new(path)
.add_guards(route.take_guards())
.route(route),
)
} |
I've run across this and feel like its intended behavior. There should be a way to "hide" verbs on routes. If you want 405s use a |
@robjtede that seems like a reasonable compromise to me. Thanks! |
The following example illustrates the issue:
Attempting to send a
POST /index
will fail with 404, where 405 is actually the appropriate error code for such a case.This is a regression compared to 1.x, as I previously reported the same issue...
The text was updated successfully, but these errors were encountered: