OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library shelf.pipeline; | |
6 | |
7 import 'handler.dart'; | 5 import 'handler.dart'; |
8 import 'middleware.dart'; | 6 import 'middleware.dart'; |
9 | 7 |
10 /// A helper that makes it easy to compose a set of [Middleware] and a | 8 /// A helper that makes it easy to compose a set of [Middleware] and a |
11 /// [Handler]. | 9 /// [Handler]. |
12 /// | 10 /// |
13 /// var handler = const Pipeline() | 11 /// var handler = const Pipeline() |
14 /// .addMiddleware(loggingMiddleware) | 12 /// .addMiddleware(loggingMiddleware) |
15 /// .addMiddleware(cachingMiddleware) | 13 /// .addMiddleware(cachingMiddleware) |
16 /// .addHandler(application); | 14 /// .addHandler(application); |
(...skipping 19 matching lines...) Expand all Loading... |
36 /// [Request] if all of the middleware in the pipeline have passed the request | 34 /// [Request] if all of the middleware in the pipeline have passed the request |
37 /// through. | 35 /// through. |
38 Handler addHandler(Handler handler) { | 36 Handler addHandler(Handler handler) { |
39 if (_middleware == null) return handler; | 37 if (_middleware == null) return handler; |
40 return _parent.addHandler(_middleware(handler)); | 38 return _parent.addHandler(_middleware(handler)); |
41 } | 39 } |
42 | 40 |
43 /// Exposes this pipeline of [Middleware] as a single middleware instance. | 41 /// Exposes this pipeline of [Middleware] as a single middleware instance. |
44 Middleware get middleware => addHandler; | 42 Middleware get middleware => addHandler; |
45 } | 43 } |
OLD | NEW |