diff --git a/README.markdown b/README.markdown index b294a80d4..822cfb047 100644 --- a/README.markdown +++ b/README.markdown @@ -327,12 +327,34 @@ Error handlers run within the same context as routes and before filters. ### Not Found -Whenever no route matches, the `notFound` handler is invoked: +Whenever no route matches, the `notFound` handler is invoked. The default behavior is: notFound {

Not found. Bummer.

} +* _ScalatraServlet_: send a 404 response +* _ScalatraFilter_: pass the request to the servlet filter chain + +### Method not allowed + +If a route matches for other methods, but not the requested method, the +`methodNotAllowed` handler is invoked. The default handler sends HTTP +status 405 with an `Allow` header containing a comma-separated list of the +supported methods. + +The default behavior is adequate for most apps. The most likely reasons +to override this behavior are: + +1. You don't want to expose the supported methods. + +2. You are in a ScalatraFilter and know the servlet filter chain can +handle the request. + + methodNotAllowed { allow: Set[HttpMethod] => + filterChain.doFilter(request, response) + } + ### Error The `error` handler is invoked any time an exception is raised from a route block or a filter. The throwable can be obtained from the `caughtThrowable` instance variable. This variable is not defined outside the `error` block. diff --git a/notes/2.0.0.M5.markdown b/notes/2.0.0.M5.markdown index aa3ca3bbb..2e58dd62f 100644 --- a/notes/2.0.0.M5.markdown +++ b/notes/2.0.0.M5.markdown @@ -1,5 +1,6 @@ ## scalatra * Fix dynamic variables leaking memory on redeploy. [(GH-74)](http://github.com/scalatra/scalatra/issues/74) +* Send 405 and Allow header if other methods match. [(GH-50)](http://github.com/scalatra/scalatra/issues/50) * Support bodies and headers in halt. [(GH-79)](http://github.com/scalatra/scalatra/issues/79) * Support PATCH requests. [(GH-51)](http://github.com/scalatra/scalatra/issues/51)