|
@@ -74,17 +74,32 @@ class Router {
|
|
|
|
|
|
final TreeMap<String, Dest> routes = Maps.newTreeMap(); // path->dest
|
|
final TreeMap<String, Dest> routes = Maps.newTreeMap(); // path->dest
|
|
|
|
|
|
|
|
+ synchronized Dest add(WebApp.HTTP httpMethod, String path,
|
|
|
|
+ Class<? extends Controller> cls,
|
|
|
|
+ String action, List<String> names){
|
|
|
|
+ return addWithOptionalDefaultView(
|
|
|
|
+ httpMethod, path, cls, action, names, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ synchronized Dest addWithoutDefaultView(WebApp.HTTP httpMethod,
|
|
|
|
+ String path, Class<? extends Controller> cls, String action,
|
|
|
|
+ List<String> names){
|
|
|
|
+ return addWithOptionalDefaultView(httpMethod, path, cls, action,
|
|
|
|
+ names, false);
|
|
|
|
+ }
|
|
/**
|
|
/**
|
|
* Add a route to the router.
|
|
* Add a route to the router.
|
|
* e.g., add(GET, "/foo/show", FooController.class, "show", [name...]);
|
|
* e.g., add(GET, "/foo/show", FooController.class, "show", [name...]);
|
|
* The name list is from /foo/show/:name/...
|
|
* The name list is from /foo/show/:name/...
|
|
*/
|
|
*/
|
|
- synchronized Dest add(WebApp.HTTP httpMethod, String path,
|
|
|
|
- Class<? extends Controller> cls,
|
|
|
|
- String action, List<String> names) {
|
|
|
|
|
|
+ synchronized Dest addWithOptionalDefaultView(WebApp.HTTP httpMethod,
|
|
|
|
+ String path, Class<? extends Controller> cls,
|
|
|
|
+ String action, List<String> names, boolean defaultViewNeeded) {
|
|
LOG.debug("adding {}({})->{}#{}", new Object[]{path, names, cls, action});
|
|
LOG.debug("adding {}({})->{}#{}", new Object[]{path, names, cls, action});
|
|
Dest dest = addController(httpMethod, path, cls, action, names);
|
|
Dest dest = addController(httpMethod, path, cls, action, names);
|
|
- addDefaultView(dest);
|
|
|
|
|
|
+ if (defaultViewNeeded) {
|
|
|
|
+ addDefaultView(dest);
|
|
|
|
+ }
|
|
return dest;
|
|
return dest;
|
|
}
|
|
}
|
|
|
|
|