2016-11-25 23:22:33 +00:00
|
|
|
part of angel_route.src.router;
|
|
|
|
|
|
|
|
class RoutingResult {
|
|
|
|
final Match match;
|
|
|
|
final RoutingResult nested;
|
|
|
|
final Map<String, dynamic> params = {};
|
2016-11-27 22:24:30 +00:00
|
|
|
final Route shallowRoute;
|
|
|
|
final Router shallowRouter;
|
2016-11-25 23:22:33 +00:00
|
|
|
final String tail;
|
|
|
|
|
|
|
|
RoutingResult get deepest {
|
|
|
|
var search = this;
|
|
|
|
|
|
|
|
while (search.nested != null) search = search.nested;
|
|
|
|
|
|
|
|
return search;
|
|
|
|
}
|
|
|
|
|
2016-11-27 22:24:30 +00:00
|
|
|
Route get route => deepest.shallowRoute;
|
|
|
|
Router get router => deepest.shallowRouter;
|
2016-11-25 23:22:33 +00:00
|
|
|
|
|
|
|
List get handlers {
|
2016-11-27 22:24:30 +00:00
|
|
|
return []..addAll(shallowRouter.middleware)..addAll(shallowRoute.handlers);
|
2016-11-25 23:22:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
List get allHandlers {
|
|
|
|
final handlers = [];
|
|
|
|
var search = this;
|
|
|
|
|
|
|
|
while (search != null) {
|
|
|
|
handlers.addAll(search.handlers);
|
|
|
|
search = search.nested;
|
|
|
|
}
|
|
|
|
|
|
|
|
return handlers;
|
|
|
|
}
|
|
|
|
|
|
|
|
RoutingResult(
|
|
|
|
{this.match,
|
|
|
|
Map<String, dynamic> params: const {},
|
|
|
|
this.nested,
|
2016-11-27 22:24:30 +00:00
|
|
|
this.shallowRoute,
|
|
|
|
this.shallowRouter,
|
2016-11-25 23:22:33 +00:00
|
|
|
this.tail}) {
|
|
|
|
this.params.addAll(params ?? {});
|
|
|
|
}
|
|
|
|
}
|