handler property

Handler handler

Exposes this cascade as a single handler.

This handler will call each inner handler in the cascade until one returns an acceptable response, and return that. If no inner handlers return an acceptable response, this will return the final response.

Implementation

Handler get handler {
  final handler = _handler;
  if (handler == null) {
    throw StateError("Can't get a handler for a cascade with no inner "
        'handlers.');
  }

  return (request) {
    if (_parent!._handler == null) return handler(request);
    return Future.sync(() => _parent!.handler(request)).then((response) {
      if (_shouldCascade(response)) return handler(request);
      return response;
    });
  };
}