Skip to content

Commit

Permalink
Document notFound and methodNotAllowed. #50
Browse files Browse the repository at this point in the history
  • Loading branch information
rossabaker committed Aug 6, 2011
1 parent 57f373f commit fa23da4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.markdown
Expand Up @@ -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 {
<h1>Not found. Bummer.</h1>
}

* _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.
Expand Down
1 change: 1 addition & 0 deletions 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)

Expand Down

0 comments on commit fa23da4

Please sign in to comment.