| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 static Future<BarbackServer> bind(String host, int port, Barback barback, | 48 static Future<BarbackServer> bind(String host, int port, Barback barback, |
| 49 String rootPackage) { | 49 String rootPackage) { |
| 50 return HttpServer.bind(host, port) | 50 return HttpServer.bind(host, port) |
| 51 .then((server) => new BarbackServer._(server, barback, rootPackage)); | 51 .then((server) => new BarbackServer._(server, barback, rootPackage)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 BarbackServer._(HttpServer server, this.barback, this._rootPackage) | 54 BarbackServer._(HttpServer server, this.barback, this._rootPackage) |
| 55 : _server = server, | 55 : _server = server, |
| 56 port = server.port, | 56 port = server.port, |
| 57 address = server.address { | 57 address = server.address { |
| 58 _server.listen(_handleRequest, onError: (error) { | 58 _server.listen(_handleRequest, onError: (error, stackTrace) { |
| 59 _resultsController.addError(error); | 59 _resultsController.addError(error, stackTrace); |
| 60 close(); | 60 close(); |
| 61 }); | 61 }); |
| 62 } | 62 } |
| 63 | 63 |
| 64 /// Closes this server. | 64 /// Closes this server. |
| 65 Future close() { | 65 Future close() { |
| 66 _server.close(); | 66 _server.close(); |
| 67 _resultsController.close(); | 67 _resultsController.close(); |
| 68 } | 68 } |
| 69 | 69 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 bool get isSuccess => error == null; | 222 bool get isSuccess => error == null; |
| 223 | 223 |
| 224 /// Whether the request was served unsuccessfully. | 224 /// Whether the request was served unsuccessfully. |
| 225 bool get isFailure => !isSuccess; | 225 bool get isFailure => !isSuccess; |
| 226 | 226 |
| 227 BarbackServerResult._success(this.url, this.id) | 227 BarbackServerResult._success(this.url, this.id) |
| 228 : error = null; | 228 : error = null; |
| 229 | 229 |
| 230 BarbackServerResult._failure(this.url, this.id, this.error); | 230 BarbackServerResult._failure(this.url, this.id, this.error); |
| 231 } | 231 } |
| OLD | NEW |