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

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: nits 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..195e48ea0baead51d63defb852d3cc8475dcb0ca 100644
--- a/example/example_server.dart
+++ b/example/example_server.dart
@@ -5,14 +5,17 @@
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);
- 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;
+
+ print('Serving at http://${server.address.host}:${server.port}');
}
shelf.Response _echoRequest(shelf.Request request) {
« 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