Add example/example.dart
Update code in README
diff --git a/README.md b/README.md
index 03fa33c..9417820 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,13 @@
import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:shelf_proxy/shelf_proxy.dart';
-void main() {
- shelf_io.serve(proxyHandler("https://www.dartlang.org"), 'localhost', 8080)
- .then((server) {
- print('Proxying at http://${server.address.host}:${server.port}');
- });
+void main() async {
+ var server = await shelf_io.serve(
+ proxyHandler("https://dart.dev"),
+ 'localhost',
+ 8080,
+ );
+
+ print('Proxying at http://${server.address.host}:${server.port}');
}
```
diff --git a/example/example.dart b/example/example.dart
new file mode 100644
index 0000000..bdb4749
--- /dev/null
+++ b/example/example.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:shelf/shelf_io.dart' as shelf_io;
+import 'package:shelf_proxy/shelf_proxy.dart';
+
+void main() async {
+ var server = await shelf_io.serve(
+ proxyHandler("https://dart.dev"),
+ 'localhost',
+ 8080,
+ );
+
+ print('Proxying at http://${server.address.host}:${server.port}');
+}