src/main/java/org/eiichiro/bootleg/Routing.java
public void add(Verb verb, String pattern, Class<?> endpoint, String method) {
		Preconditions.checkArgument(pattern != null, 
				"Parameter 'pattern' must not be [" + pattern + "]");
		Preconditions.checkArgument(pattern.startsWith("/"), 
				"Parameter 'pattern' must start with [/]");
		Preconditions.checkArgument(endpoint != null, 
				"Parameter 'endpoint' must not be [" + endpoint + "]");
		Preconditions.checkArgument(method != null, 
				"Parameter 'method' must not be [" + method + "]");
		
		for (Method m : endpoint.getMethods()) {
			if (m.getName().equals(method)) {
				URITemplate template = null;
				
				if (templates.containsKey(pattern)) {
					template = templates.get(pattern);
				} else {
					template = new URITemplate(pattern);
					templates.put(pattern, template);
				}
				
				Map<Verb, Method> methods = null;
				
				if (routes.containsKey(template)) {
					methods = routes.get(template);
				} else {
					methods = new HashMap<Verb, Method>();
					routes.put(template, methods);
				}
				
				methods.put(verb, m);
				return;
			}
		}
		
		throw new IllegalArgumentException("Method [" + method
				+ "] does not exist on Web endpoint [" + endpoint + "]");
	}
public void add(Verb verb, String pattern, Class<?> endpoint, String method) {
		Preconditions.checkArgument(pattern != null, 
				"Parameter 'pattern' must not be [" + pattern + "]");
		Preconditions.checkArgument(pattern.startsWith("/"), 
				"Parameter 'pattern' must start with [/]");
		Preconditions.checkArgument(endpoint != null, 
				"Parameter 'endpoint' must not be [" + endpoint + "]");
		Preconditions.checkArgument(method != null, 
				"Parameter 'method' must not be [" + method + "]");
		
		for (Method m : endpoint.getMethods()) {
			if (m.getName().equals(method)) {
				URITemplate template = null;
				
				if (templates.containsKey(pattern)) {
					template = templates.get(pattern);
				} else {
					template = new URITemplate(pattern);
					templates.put(pattern, template);
				}
				
				Map<Verb, Method> methods = null;
				
				if (routes.containsKey(template)) {
					methods = routes.get(template);
				} else {
					methods = new HashMap<Verb, Method>();
					routes.put(template, methods);
				}
				
				methods.put(verb, m);
				return;
			}
		}
		
		throw new IllegalArgumentException("Method [" + method
				+ "] does not exist on Web endpoint [" + endpoint + "]");
	}
public void add ( Verb verb , String pattern , Class < ? > endpoint , String method ) { Preconditions . checkArgument ( pattern != null , "Parameter 'pattern' must not be [" + pattern + "]" ) ; Preconditions . checkArgument ( pattern . startsWith ( "/" ) , "Parameter 'pattern' must start with [/]" ) ; Preconditions . checkArgument ( endpoint != null , "Parameter 'endpoint' must not be [" + endpoint + "]" ) ; Preconditions . checkArgument ( method != null , "Parameter 'method' must not be [" + method + "]" ) ; for ( Method m : endpoint . getMethods ( ) ) { if ( m . getName ( ) . equals ( method ) ) { URITemplate template = null ; if ( templates . containsKey ( pattern ) ) { template = templates . get ( pattern ) ; } else { template = new URITemplate ( pattern ) ; templates . put ( pattern , template ) ; } Map < Verb , Method > methods = null ; if ( routes . containsKey ( template ) ) { methods = routes . get ( template ) ; } else { methods = new HashMap < Verb , Method > ( ) ; routes . put ( template , methods ) ; } methods . put ( verb , m ) ; return ; } } throw new IllegalArgumentException ( "Method [" + method + "] does not exist on Web endpoint [" + endpoint + "]" ) ; }
Adds URL routing pattern.
The routing pattern can be specified as URI template format and the path
variables can be passed to Web endpoint method like this:
<pre>
{@code @Override}
public void routing(Routing routing) {
routing.add("/user/{id}/*", User.class, "handle");
}
</pre>
<pre>
{@code}
public class User {

// '/user/{id}/*' is routed to this method.
public void handle({@code} String id) {
...
</pre>
<b>Note</b>: If a certain URI matches to multiple routing patterns, the
routing pattern that has the most path segments (split by '/') is used in
preference to the others. If there are multiple routing patterns that
have the same path segments, the first-specified one is used.

@param pattern URL routing pattern as URI template format.
@param endpoint Web endpoint class corresponding to the routing pattern.
@param method Web endpoint method corresponding to the routing pattern.
@see URITemplate
Adds URL routing pattern . The routing pattern can be specified as URI template format and the path variables can be passed to Web endpoint method like this : <pre > { @code @Override } public void routing ( Routing routing ) { routing . add ( / user / { id } / * User . class handle ) ; } < / pre > <pre > { @code } public class User {