platform/lib/src/middleware_pipeline.dart

23 lines
584 B
Dart
Raw Normal View History

2016-11-25 23:22:33 +00:00
import 'router.dart';
2016-12-19 04:43:55 +00:00
/// A chain of arbitrary handlers obtained by routing a path.
2016-11-25 23:22:33 +00:00
class MiddlewarePipeline {
2016-12-19 04:43:55 +00:00
/// All the possible routes that matched the given path.
2016-11-25 23:22:33 +00:00
final List<RoutingResult> routingResults;
2017-11-25 00:26:06 +00:00
List _handlers;
2016-11-25 23:22:33 +00:00
2016-12-19 04:43:55 +00:00
/// An ordered list of every handler delegated to handle this request.
2016-11-25 23:22:33 +00:00
List get handlers {
2017-11-25 00:26:06 +00:00
if (_handlers != null) return _handlers;
2016-11-25 23:22:33 +00:00
final handlers = [];
for (RoutingResult result in routingResults) {
handlers.addAll(result.allHandlers);
}
2017-11-25 00:26:06 +00:00
return _handlers = handlers;
2016-11-25 23:22:33 +00:00
}
MiddlewarePipeline(this.routingResults);
}