Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Unimplemented methods should return 405 status code #49

Open
rybesh opened this Issue · 3 comments

3 participants

@rybesh

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.

@piotrek-r

Shouldn't this be 501? 4xx indicates client-side problems and not implementing a method is more like server-side thing to get done.

@rybesh

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).

@conradev

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.