| OLD | NEW |
| (Empty) |
| 1 An implementation of `dart:io`'s [HttpServer][] that wraps multiple servers and | |
| 2 forwards methods to all of them. It's useful for serving the same application on | |
| 3 multiple network interfaces while still having a unified way of controlling the | |
| 4 servers. In particular, it supports serving on both the IPv4 and IPv6 loopback | |
| 5 addresses using [HttpMultiServer.loopback][]. | |
| 6 | |
| 7 ```dart | |
| 8 import 'package:http_multi_server/http_multi_server.dart'; | |
| 9 import 'package:shelf/shelf.dart' as shelf; | |
| 10 import 'package:shelf/shelf_io.dart' as shelf_io; | |
| 11 | |
| 12 void main() { | |
| 13 // Both http://127.0.0.1:8080 and http://[::1]:8080 will be bound to the same | |
| 14 // server. | |
| 15 HttpMultiServer.loopback(8080).then((server) { | |
| 16 shelf_io.serveRequests(server, (request) { | |
| 17 return new shelf.Response.ok("Hello, world!"); | |
| 18 }); | |
| 19 }); | |
| 20 } | |
| 21 ``` | |
| 22 | |
| 23 [HttpServer]: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/da
rt-io.HttpServer | |
| 24 | |
| 25 [HttpMultiServer.loopback]: https://api.dartlang.org/apidocs/channels/stable/dar
tdoc-viewer/http_multi_server/http_multi_server.HttpMultiServer#id_loopback | |
| OLD | NEW |