undertow-io/undertow — pull request #231 by billoneil (2014-07-29 02:29:36+00:00)
Title: Added some convience methods to routing handler.  Handle an edge case fo...

Tests initially failed from the following.

Given 3 routes
GET /foo
DELETE /foo
GET /bar

A request to DELETE /bar will result in a 404 instead of a 405.

PathTemplateMatcher matcher = matches.get(exchange.getRequestMethod());
if (matcher == null) {
invalidMethodHandler.handleRequest(exchange);
return;
}
PathTemplateMatcher.PathMatchResult match = matcher.match(exchange.getRelativePath());
if (match == null) {
fallbackHandler.handleRequest(exchange);
return;
}

Since the routes are first mapped on the HttpMethod we will get a PathTemplateMatcher back which contains DELETE /foo. It will then fall through to the next if and return a 404. I think the expected behavior should be 405? Is looping over ALL PathTemplateMatchers the only way to catch this?