ninja icon indicating copy to clipboard operation
ninja copied to clipboard

Ninja returns 404 Not Found when it should return 405 Method Not Allowed

Open omervk opened this issue 9 years ago • 1 comments

When a route is defined for a specific path with a specific method and a different method is used, the server should return 405 Method Not Allowed.

e.g., if we define a route /foo/bar that answers the GET method and call it with HEAD, we should receive 405 Method Not Allowed. Currently we receive 404 Not Found.

omervk avatar Mar 21 '16 07:03 omervk

There has been lots of debate over the years about 405 vs. 404 errors. A somewhat good summary of the various arguments is here http://stackoverflow.com/questions/15684764/http-405-web-server-compliance

Supporting this by default would require a less efficient routing lookup. Right now, I believe it evaluates the method first, then looks up and evaluates the url for the first match. To support 405, you'd have to lookup urls first followed by a method -- which is definitely less efficient.

If you really wanted to support this, it'd be 100% doable with your own Routes.java file defining default error results if no other GET, HEAD, POST, etc. methods happened to match.

jjlauer avatar Mar 22 '16 17:03 jjlauer