Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: pkg/shelf/lib/src/pipeline.dart

Issue 814113004: Pull args, intl, logging, shelf, and source_maps out of the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also csslib. Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/shelf/lib/src/middleware.dart ('k') | pkg/shelf/lib/src/request.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library shelf.pipeline;
6
7 import 'handler.dart';
8 import 'middleware.dart';
9
10 /// A helper that makes it easy to compose a set of [Middleware] and a
11 /// [Handler].
12 ///
13 /// var handler = const Pipeline()
14 /// .addMiddleware(loggingMiddleware)
15 /// .addMiddleware(cachingMiddleware)
16 /// .addHandler(application);
17 class Pipeline {
18 final Pipeline _parent;
19 final Middleware _middleware;
20
21 const Pipeline()
22 : _middleware = null,
23 _parent = null;
24
25 Pipeline._(this._middleware, this._parent);
26
27 /// Returns a new [Pipeline] with [middleware] added to the existing set of
28 /// [Middleware].
29 ///
30 /// [middleware] will be the last [Middleware] to process a request and
31 /// the first to process a response.
32 Pipeline addMiddleware(Middleware middleware) =>
33 new Pipeline._(middleware, this);
34
35 /// Returns a new [Handler] with [handler] as the final processor of a
36 /// [Request] if all of the middleware in the pipeline have passed the request
37 /// through.
38 Handler addHandler(Handler handler) {
39 if (_middleware == null) return handler;
40 return _parent.addHandler(_middleware(handler));
41 }
42
43 /// Exposes this pipeline of [Middleware] as a single middleware instance.
44 Middleware get middleware => addHandler;
45 }
OLDNEW
« no previous file with comments | « pkg/shelf/lib/src/middleware.dart ('k') | pkg/shelf/lib/src/request.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698