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

Side by Side Diff: lib/src/util/one_off_handler.dart

Issue 1580973002: Get rid of all the library tags. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « lib/src/util/multi_channel.dart ('k') | lib/src/util/path_handler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 test.util.one_off_handler;
6
7 import 'package:path/path.dart' as p; 5 import 'package:path/path.dart' as p;
8 import 'package:shelf/shelf.dart' as shelf; 6 import 'package:shelf/shelf.dart' as shelf;
9 7
10 /// A Shelf handler that provides support for one-time handlers. 8 /// A Shelf handler that provides support for one-time handlers.
11 /// 9 ///
12 /// This is useful for handlers that only expect to be hit once before becoming 10 /// This is useful for handlers that only expect to be hit once before becoming
13 /// invalid and don't need to have a persistent URL. 11 /// invalid and don't need to have a persistent URL.
14 class OneOffHandler { 12 class OneOffHandler {
15 /// A map from URL paths to handlers. 13 /// A map from URL paths to handlers.
16 final _handlers = new Map<String, shelf.Handler>(); 14 final _handlers = new Map<String, shelf.Handler>();
(...skipping 21 matching lines...) Expand all
38 _onRequest(shelf.Request request) { 36 _onRequest(shelf.Request request) {
39 var components = p.url.split(request.url.path); 37 var components = p.url.split(request.url.path);
40 if (components.isEmpty) return new shelf.Response.notFound(null); 38 if (components.isEmpty) return new shelf.Response.notFound(null);
41 39
42 var path = components.removeAt(0); 40 var path = components.removeAt(0);
43 var handler = _handlers.remove(path); 41 var handler = _handlers.remove(path);
44 if (handler == null) return new shelf.Response.notFound(null); 42 if (handler == null) return new shelf.Response.notFound(null);
45 return handler(request.change(path: path)); 43 return handler(request.change(path: path));
46 } 44 }
47 } 45 }
OLDNEW
« no previous file with comments | « lib/src/util/multi_channel.dart ('k') | lib/src/util/path_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698