action property
Function?
get
action
The function that handles the request, read once: the last function
of controllers, or the controller method that a
ControllerAction (Route.get<C>(path, (C c) => c.index)) or a
(C c) => c.index function picks. The controller comes from the
container. Null when the route has no controller function.
Implementation
Function? get action {
if (!_actionRead) {
Object? list = controllers;
Object? last = list is List<dynamic> && list.isNotEmpty
? list.last
: null;
String where = '$method $path';
if (last is ControllerAction) {
_action = last.resolve(Dox().ioc, where);
} else if (last is Function) {
_action = ControllerTypes.select(last, Dox().ioc, where) ?? last;
}
_actionRead = true;
}
return _action;
}