OLD | NEW |
1 ## Proxy for Shelf | 1 ## Proxy for Shelf |
2 | 2 |
| 3 [![Build Status](https://drone.io/github.com/dart-lang/shelf_proxy/status.png)](
https://drone.io/github.com/dart-lang/shelf_proxy/latest) |
| 4 |
3 `shelf_proxy` is a [Shelf][] handler that proxies requests to an external | 5 `shelf_proxy` is a [Shelf][] handler that proxies requests to an external |
4 server. It can be served directly and used as a proxy server, or it can be | 6 server. It can be served directly and used as a proxy server, or it can be |
5 mounted within a larger application to proxy only certain URLs. | 7 mounted within a larger application to proxy only certain URLs. |
6 | 8 |
7 [Shelf]: pub.dartlang.org/packages/shelf | 9 [Shelf]: pub.dartlang.org/packages/shelf |
8 | 10 |
9 ```dart | 11 ```dart |
10 import 'package:shelf/shelf_io.dart' as shelf_io; | 12 import 'package:shelf/shelf_io.dart' as shelf_io; |
11 import 'package:shelf_proxy/shelf_proxy.dart'; | 13 import 'package:shelf_proxy/shelf_proxy.dart'; |
12 | 14 |
13 void main() { | 15 void main() { |
14 shelf_io.serve(proxyHandler("https://www.dartlang.org"), 'localhost', 8080) | 16 shelf_io.serve(proxyHandler("https://www.dartlang.org"), 'localhost', 8080) |
15 .then((server) { | 17 .then((server) { |
16 print('Proxying at http://${server.address.host}:${server.port}'); | 18 print('Proxying at http://${server.address.host}:${server.port}'); |
17 }); | 19 }); |
18 } | 20 } |
19 ``` | 21 ``` |
OLD | NEW |