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

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

Issue 1053443002: Rename the package to "test". (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 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/remote_exception.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 unittest.one_off_handler; 5 library test.one_off_handler;
6 6
7 import 'package:path/path.dart' as p; 7 import 'package:path/path.dart' as p;
8 import 'package:shelf/shelf.dart' as shelf; 8 import 'package:shelf/shelf.dart' as shelf;
9 9
10 /// A Shelf handler that provides support for one-time handlers. 10 /// A Shelf handler that provides support for one-time handlers.
11 /// 11 ///
12 /// This is useful for handlers that only expect to be hit once before becoming 12 /// 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. 13 /// invalid and don't need to have a persistent URL.
14 class OneOffHandler { 14 class OneOffHandler {
15 /// A map from URL paths to handlers. 15 /// A map from URL paths to handlers.
(...skipping 22 matching lines...) Expand all
38 _onRequest(shelf.Request request) { 38 _onRequest(shelf.Request request) {
39 // Skip the first component because it's always "/". 39 // Skip the first component because it's always "/".
40 var components = p.url.split(request.url.path).skip(1).toList(); 40 var components = p.url.split(request.url.path).skip(1).toList();
41 if (components.isEmpty) return new shelf.Response.notFound(null); 41 if (components.isEmpty) return new shelf.Response.notFound(null);
42 42
43 var handler = _handlers.remove(components.removeAt(0)); 43 var handler = _handlers.remove(components.removeAt(0));
44 if (handler == null) return new shelf.Response.notFound(null); 44 if (handler == null) return new shelf.Response.notFound(null);
45 return handler(request); 45 return handler(request);
46 } 46 }
47 } 47 }
OLDNEW
« no previous file with comments | « lib/src/util/multi_channel.dart ('k') | lib/src/util/remote_exception.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698