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

Side by Side Diff: pkg/shelf/test/test_util.dart

Issue 219283008: pkg/shelf (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cl nits Created 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/shelf/test/string_scanner_test.dart ('k') | pkg/shelf/tool/hop_runner.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.test_util;
6
7 import 'dart:async';
8
9 import 'package:shelf/shelf.dart';
10 import 'package:shelf/src/util.dart';
11
12 /// A simple, synchronous handler for [Request].
13 ///
14 /// By default, replies with a status code 200, empty headers, and
15 /// `Hello from ${request.pathInfo}`.
16 Response syncHandler(Request request, {int statusCode,
17 Map<String, String> headers}) {
18 if (statusCode == null) statusCode = 200;
19 return new Response(statusCode, headers: headers,
20 body: 'Hello from ${request.pathInfo}');
21 }
22
23 /// Calls [syncHandler] and wraps the response in a [Future].
24 Future<Response> asyncHandler(Request request) =>
25 new Future(() => syncHandler(request));
26
27 /// Makes a simple GET request to [handler] and returns the result.
28 Future<Response> makeSimpleRequest(Handler handler) =>
29 syncFuture(() => handler(_request));
30
31 final _request = new Request('/', '', 'GET', '', '1.1',
32 Uri.parse('http://localhost/'), {});
OLDNEW
« no previous file with comments | « pkg/shelf/test/string_scanner_test.dart ('k') | pkg/shelf/tool/hop_runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698