onCall method

  1. @override
FutureOr<Message> onCall(
  1. Request request
)
override

Implementation

@override
FutureOr<Message> onCall(Request request) {
  var n = request.path
      .resolveFor(binding._childGateway?.childrenBinding.keys.toList() ?? []);
  if (n.segment.isRoot && binding.component.root == null) {
    throw NotFoundException(
        "/${request.path.processed.last.segment.name}/$n");
  }
  if (n.segment.isUnknown) {
    if (binding.component.handleUnknownAsRoot) {
      return binding.rootBinding!.findCalling.calling(request);
    }
    throw NotFoundException(
        "${request.path.next} : /${request.path.processed.last.segment.name}");
  }
  if (n.segment.isRoot) {
    return binding.rootBinding!.findCalling.calling(request);
  }
  return binding.childBinding!.findCalling.calling(request);

  //
  //
  // binding.rootBinding.findCalling.calling(request);
  //
  // if (n.segment.isRoot) {
  //   return (binding.rootBinding ?? binding.exceptionHandler.unknown)
  //       .findCalling
  //       .calling(request);
  // } else if (n.segment.isUnknown) {
  //   return (binding.component.handleUnknownAsRoot
  //           ? binding.rootBinding!
  //           : binding.exceptionHandler.unknown)
  //       .findCalling
  //       .calling(request);
  // } else {
  //   return (binding._childGateway!.binding).findCalling.calling(request);
  // }
  // } on Exception catch (e) {
  //   return binding.exceptionHandler[e.runtimeType].findCalling
  //       .calling(request);
  // }
}