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

Side by Side Diff: pkg/http_server/lib/http_server.dart

Issue 756493002: pkg/http_server: move to multi-lib layout (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: readme fixup Created 6 years 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/http_server/README.md ('k') | pkg/http_server/lib/src/http_body.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) 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 /** 5 /**
6 * A library for serving HTTP requests and resources. 6 * A library for serving HTTP requests and resources.
7 * 7 *
8 * ## Installing ## 8 * ## Installing ##
9 * 9 *
10 * Use [pub][] to install this package. Add the following to your 10 * Use [pub][] to install this package. Add the following to your
11 * `pubspec.yaml` file. 11 * `pubspec.yaml` file.
12 * 12 *
13 * dependencies: 13 * dependencies:
14 * http_server: any 14 * http_server: any
15 * 15 *
16 * Then run `pub install`. 16 * Then run `pub install`.
17 * 17 *
18 * For more information, see the 18 * For more information, see the
19 * [http_server package on pub.dartlang.org][pub]. 19 * [http_server package on pub.dartlang.org][pub].
20 * 20 *
21 * ## Basic usage 21 * ## Basic usage
22 * 22 *
23 * Here is a short example of how to serve all files from the current 23 * Here is a short example of how to serve all files from the current
24 * directory. 24 * directory.
25 * 25 *
26 * import 'dart:io'; 26 * import 'dart:io';
27 * import 'dart:async'; 27 * import 'dart:async';
28 * import 'package:http_server/http_server.dart'; 28 * import 'package:http_server/http_server.dart';
29 * 29 *
30 * void main() { 30 * void main() {
31 * var staticFiles = new VirtualDirectory('.') 31 * var staticFiles = new VirtualDirectory('.')
32 * ..allowDirectoryListing = true; 32 * ..allowDirectoryListing = true;
33 * 33 *
34 * runZoned(() { 34 * runZoned(() {
35 * HttpServer.bind('0.0.0.0', 7777).then((server) { 35 * HttpServer.bind('0.0.0.0', 7777).then((server) {
36 * print('Server running'); 36 * print('Server running');
37 * server.listen(staticFiles.serveRequest); 37 * server.listen(staticFiles.serveRequest);
38 * }); 38 * });
39 * }, 39 * },
40 * onError: (e, stackTrace) => print('Oh noes! $e $stackTrace')); 40 * onError: (e, stackTrace) => print('Oh noes! $e $stackTrace'));
41 * } 41 * }
42 * 42 *
43 * ## Virtual directory 43 * ## Virtual directory
44 * 44 *
45 * The [VirtualDirectory] class makes it easy to serve static content 45 * The [VirtualDirectory] class makes it easy to serve static content
46 * from the file system. It supports: 46 * from the file system. It supports:
47 * 47 *
48 * * Range-based requests. 48 * * Range-based requests.
49 * * If-Modified-Since based caching. 49 * * If-Modified-Since based caching.
50 * * Automatic GZip-compression of content. 50 * * Automatic GZip-compression of content.
51 * * Following symlinks, either throughout the system or inside 51 * * Following symlinks, either throughout the system or inside
52 * a jailed root. 52 * a jailed root.
53 * * Directory listing. 53 * * Directory listing.
54 * 54 *
55 * See [VirtualDirectory] for more information. 55 * See [VirtualDirectory] for more information.
56 * 56 *
57 * ## Virtual host 57 * ## Virtual host
58 * 58 *
59 * The [VirtualHost] class helps to serve multiple hosts on the same 59 * The [VirtualHost] class helps to serve multiple hosts on the same
60 * address, by using the `Host` field of the incoming requests. It also 60 * address, by using the `Host` field of the incoming requests. It also
61 * works with wildcards for sub-domains. 61 * works with wildcards for sub-domains.
62 * 62 *
63 * var virtualHost = new VirtualHost(server); 63 * var virtualHost = new VirtualHost(server);
64 * // Filter out on a specific host 64 * // Filter out on a specific host
65 * var stream1 = virtualServer.addHost('static.myserver.com'); 65 * var stream1 = virtualServer.addHost('static.myserver.com');
66 * // Wildcard for any other sub-domains. 66 * // Wildcard for any other sub-domains.
67 * var stream2 = virtualServer.addHost('*.myserver.com'); 67 * var stream2 = virtualServer.addHost('*.myserver.com');
68 * // Requets not matching any hosts. 68 * // Requets not matching any hosts.
69 * var stream3 = virtualServer.unhandled; 69 * var stream3 = virtualServer.unhandled;
70 * 70 *
71 * See [VirtualHost] for more information. 71 * See [VirtualHost] for more information.
72 * 72 *
73 * [pub]: http://pub.dartlang.org/packages/http_server 73 * [pub]: http://pub.dartlang.org/packages/http_server
74 */ 74 */
75 library http_server; 75 library http_server;
76 76
77 import 'dart:async'; 77 export 'src/http_body.dart';
78 import 'dart:convert'; 78 export 'src/http_multipart_form_data.dart';
79 import 'dart:io'; 79 export 'src/virtual_directory.dart';
80 80 export 'src/virtual_host.dart';
81 import 'package:mime/mime.dart';
82 import "package:path/path.dart";
83
84 part 'src/http_body.dart';
85 part 'src/http_body_impl.dart';
86 part 'src/http_multipart_form_data.dart';
87 part 'src/http_multipart_form_data_impl.dart';
88 part 'src/virtual_directory.dart';
89 part 'src/virtual_host.dart';
90
OLDNEW
« no previous file with comments | « pkg/http_server/README.md ('k') | pkg/http_server/lib/src/http_body.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698