{title:'Matchers', updated:'9.0.0'}

{@link oajr.matcher.RestMatcher RestMatchers} are used to allow multiple Java methods to be tied to the same HTTP method and path but differentiated by some request attribute such as a specific header value.

Example:

| // GET method that gets invoked for administrators | @RestGet(path="/*", matchers=IsAdminMatcher.class) | public Object doGetForAdmin() { | ... | } | | // GET method that gets invoked for everyone else | @RestGet("/*") | public Object doGetForEveryoneElse() { | ... | }

The interface for matchers is simple:

| public class IsAdminMatcher extends RestMatcher { | | @Override /* RestMatcher */ | public boolean matches(RestRequest req) { | return req.isUserInRole("ADMINS_GROUP"); | } | }