Description
It would be great if Express would return status code 405 when a client requests a resource (aka a path) with an http verb that is not allowed. Today express will return a 404, which isn't quite correct since the path may be valid and found, it just doesn't support that verb. Here is the doc I'm reading for the definitions of status code 404 and 405: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
404 Not Found
The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.405 Method Not Allowed
The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.
Here is an example. In my server.coffee file I have the following definition:
app.get '/', (req, res) ->
res.json { players: "/v1/accounts/:accountId/players" }
Assuming I have not registered app.post '/', (req, res), when a client invokes
curl -v -d "some post data" http://localhost:9000/
The response includes "HTTP/1.1 404 Not Found" but it should be "HTTP/1.1 405 Method Not Allowed".