OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library pub.barback.server; | 5 library pub.barback.server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 static Future<BarbackServer> bind(String host, int port, Barback barback, | 49 static Future<BarbackServer> bind(String host, int port, Barback barback, |
50 String rootPackage) { | 50 String rootPackage) { |
51 return HttpServer.bind(host, port) | 51 return HttpServer.bind(host, port) |
52 .then((server) => new BarbackServer._(server, barback, rootPackage)); | 52 .then((server) => new BarbackServer._(server, barback, rootPackage)); |
53 } | 53 } |
54 | 54 |
55 BarbackServer._(HttpServer server, this.barback, this._rootPackage) | 55 BarbackServer._(HttpServer server, this.barback, this._rootPackage) |
56 : _server = server, | 56 : _server = server, |
57 port = server.port, | 57 port = server.port, |
58 address = server.address { | 58 address = server.address { |
59 _server.listen(_handleRequest, onError: (error) { | 59 _server.listen(_handleRequest, onError: (error, stackTrace) { |
60 _resultsController.addError(error); | 60 _resultsController.addError(error, stackTrace); |
61 close(); | 61 close(); |
62 }); | 62 }); |
63 } | 63 } |
64 | 64 |
65 /// Closes this server. | 65 /// Closes this server. |
66 Future close() { | 66 Future close() { |
67 _server.close(); | 67 _server.close(); |
68 _resultsController.close(); | 68 _resultsController.close(); |
69 } | 69 } |
70 | 70 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 bool get isSuccess => error == null; | 196 bool get isSuccess => error == null; |
197 | 197 |
198 /// Whether the request was served unsuccessfully. | 198 /// Whether the request was served unsuccessfully. |
199 bool get isFailure => !isSuccess; | 199 bool get isFailure => !isSuccess; |
200 | 200 |
201 BarbackServerResult._success(this.url, this.id) | 201 BarbackServerResult._success(this.url, this.id) |
202 : error = null; | 202 : error = null; |
203 | 203 |
204 BarbackServerResult._failure(this.url, this.id, this.error); | 204 BarbackServerResult._failure(this.url, this.id, this.error); |
205 } | 205 } |
OLD | NEW |