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

Unified Diff: example/example_server.dart

Issue 1660513002: pkg/shelf: use async and enable compression in example (Closed) Base URL: https://github.com/dart-lang/shelf.git@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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: example/example_server.dart
diff --git a/example/example_server.dart b/example/example_server.dart
index 5abc65e5be3d7bb2ae1417d97462026d49042f11..a9f32275adbf93f1d92d2a97bf26282ba0f140c5 100644
--- a/example/example_server.dart
+++ b/example/example_server.dart
@@ -5,16 +5,16 @@
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
-void main() {
+main() async {
var handler = const shelf.Pipeline()
.addMiddleware(shelf.logRequests())
- .addHandler(_echoRequest);
+ .addHandler(
+ (request) => new shelf.Response.ok('Request for "${request.url}"'));
- io.serve(handler, 'localhost', 8080).then((server) {
- print('Serving at http://${server.address.host}:${server.port}');
- });
-}
+ var server = await io.serve(handler, 'localhost', 8080);
+
+ // Enable content compression
+ server.autoCompress = true;
-shelf.Response _echoRequest(shelf.Request request) {
nweiz 2016/02/02 19:15:42 I think it's better to keep this as a separate fun
kevmoo 2016/02/02 19:21:24 Done.
- return new shelf.Response.ok('Request for "${request.url}"');
+ print('Serving at http://${server.address.host}:${server.port}');
}
« no previous file with comments | « no previous file | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698