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/utils.dart

Issue 1664433002: Support shelf 0.7.0. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 10 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/stream_channel.dart ('k') | pubspec.yaml » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 8
9 import 'package:async/async.dart' hide StreamQueue; 9 import 'package:async/async.dart' hide StreamQueue;
10 import 'package:crypto/crypto.dart'; 10 import 'package:crypto/crypto.dart';
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 var result = {}; 201 var result = {};
202 map1.forEach((key, value) { 202 map1.forEach((key, value) {
203 result[key] = value; 203 result[key] = value;
204 }); 204 });
205 map2.forEach((key, value) { 205 map2.forEach((key, value) {
206 result[key] = value; 206 result[key] = value;
207 }); 207 });
208 return result; 208 return result;
209 } 209 }
210 210
211 /// Returns a sink that maps events sent to [original] using [fn].
212 StreamSink mapSink(StreamSink original, fn(event)) {
213 var controller = new StreamController(sync: true);
214 controller.stream.listen(
215 (event) => original.add(fn(event)),
216 onError: (error, stackTrace) => original.addError(error, stackTrace),
217 onDone: () => original.close());
218 return controller.sink;
219 }
220
221 /// Like [runZoned], but [zoneValues] are set for the callbacks in 211 /// Like [runZoned], but [zoneValues] are set for the callbacks in
222 /// [zoneSpecification] and [onError]. 212 /// [zoneSpecification] and [onError].
223 runZonedWithValues(body(), {Map zoneValues, 213 runZonedWithValues(body(), {Map zoneValues,
224 ZoneSpecification zoneSpecification, Function onError}) { 214 ZoneSpecification zoneSpecification, Function onError}) {
225 return runZoned(() { 215 return runZoned(() {
226 return runZoned(body, 216 return runZoned(body,
227 zoneSpecification: zoneSpecification, onError: onError); 217 zoneSpecification: zoneSpecification, onError: onError);
228 }, zoneValues: zoneValues); 218 }, zoneValues: zoneValues);
229 } 219 }
230 220
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 urlSafe: urlSafe, addLineSeparator: addLineSeparator); 409 urlSafe: urlSafe, addLineSeparator: addLineSeparator);
420 } 410 }
421 411
422 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. 412 /// Returns middleware that nests all requests beneath the URL prefix [beneath].
423 shelf.Middleware nestingMiddleware(String beneath) { 413 shelf.Middleware nestingMiddleware(String beneath) {
424 return (handler) { 414 return (handler) {
425 var pathHandler = new PathHandler()..add(beneath, handler); 415 var pathHandler = new PathHandler()..add(beneath, handler);
426 return pathHandler.handler; 416 return pathHandler.handler;
427 }; 417 };
428 } 418 }
OLDNEW
« no previous file with comments | « lib/src/util/stream_channel.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698