Closed rybesh closed 5 years ago
Shouldn't this be 501? 4xx indicates client-side problems and not implementing a method is more like server-side thing to get done.
It's a client-side problem because the client has attempt to use a method unsupported by the resource. It's analogous to a 404 (where the client has requested a resource that doesn't exist).
It's simple enough to implement:
var errorResponse = function(error) {
return function(req, res) { res.send(error); };
}
app.delete('/notdeletable', errorResponse(405));
But I agree. The default error code for endpoints that exist but do not support the method should be 405
Any news on this?
This project is long dead
My bad. PR for this feature in Express 4 is here: https://github.com/strongloop/express/pull/2703.
Currently HTTP requests to a resource that specify a method unimplemented by that resource return a 404 Not Found status code. That is misleading, since the resource can be found—it just doesn't allow that method. It should return a 405 Method Not Allowed in this case.
This behavior (or at least the "Cannot [METHOD] [PATH]" message") seems to be coming from the connect lib; it's not clear to me whether it can or should be fixed there, or in express-resource.