use of act.cli.tree.TreeNode in project actframework by actframework.
the class RouterAdmin method listRoutes.
@Command(name = "act.route.list, act.route.print", help = "list routes")
@PropertySpec("method,path,compactHandler")
public Object listRoutes(@Optional("list routes in tree view") boolean tree, @Optional("specify the port name") String name, @Optional("specify route filter") String q) {
final Router router = S.blank(name) ? app.router() : app.router(name);
if (S.notBlank(q)) {
if (q.contains(".") || q.contains("[") || q.contains("*")) {
// already regex
} else {
// make it a regex
q = ".*" + q + ".*";
}
}
if (tree) {
TreeNode root = new TreeNode() {
@Override
public String id() {
return "root";
}
@Override
public String label() {
return "Router";
}
@Override
public List<TreeNode> children() {
List<TreeNode> l = new ArrayList<>();
l.add(router._GET);
l.add(router._POST);
l.add(router._PUT);
l.add(router._DEL);
return l;
}
};
return S.blank(q) ? root : new FilteredTreeNode(root, TreeNodeFilter.Common.pathMatches(q));
} else {
return routeInfoList(name, q);
}
}
Aggregations