exploreAllRoutes method
Implementation
Future<List<Map>> exploreAllRoutes(WebRequest rq) async {
var allRoutes = await getAllRoutes(rq);
List<Map> convert(List<WebRoute> routes, String parentPath, hasAuth) {
var result = <Map>[];
for (final route in routes) {
for (var method in route.methods) {
var map = route.toMap(
parentPath,
hasAuth || route.auth != null,
method,
);
result.addAll(map);
}
if (route.children.isNotEmpty) {
result.addAll(
convert(
route.children,
"$parentPath${route.path}",
hasAuth || route.auth != null,
),
);
for (var epath in route.extraPath) {
result.addAll(
convert(
route.children,
"$parentPath$epath",
hasAuth || route.auth != null,
),
);
}
}
}
return result;
}
var webRoutes = convert(allRoutes, '', false);
var index = 1;
webRoutes.sort(
(a, b) => a['fullPath'].toString().compareTo(b['fullPath'].toString()));
webRoutes = webRoutes.map((e) {
e['#'] = index++;
return e;
}).toList();
return webRoutes;
}