diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5c5e11f6..b68cc2ca 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,7 +3,8 @@
-
+
+
@@ -25,27 +26,25 @@
-
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
+
@@ -57,8 +56,8 @@
-
-
+
+
@@ -191,13 +190,11 @@
-
-
@@ -215,6 +212,8 @@
+
+
@@ -628,14 +627,7 @@
-
-
-
- 1497837231709
-
-
-
- 1497837231709
+
1497985995955
@@ -973,7 +965,14 @@
1517980874143
-
+
+ 1517980935063
+
+
+
+ 1517980935063
+
+
@@ -1009,7 +1008,7 @@
-
+
@@ -1028,7 +1027,7 @@
-
+
@@ -1068,7 +1067,6 @@
-
@@ -1093,7 +1091,8 @@
-
+
+
@@ -1218,13 +1217,6 @@
-
-
-
-
-
-
-
@@ -1251,19 +1243,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1301,17 +1280,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -1497,30 +1465,62 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 76dca643..d138c6f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ empty string.
* Deprecated `Angel.createZoneForRequest`.
* Deprecated all `Angel` methods that directly touch an `HttpServer` or `HttpRequest`.
* Created the `AngelHttp` class.
+* Removed explicit dependence on `dart:io` for `Angel`, `RequestContext`, `ResponseContext`.
# 1.1.0+3
* Modified `ResponseContext#isOpen` to also return `false` if streaming is being used.
diff --git a/lib/src/stats/metric_server.dart b/lib/src/stats/metric_server.dart
index 2c810391..8982995b 100644
--- a/lib/src/stats/metric_server.dart
+++ b/lib/src/stats/metric_server.dart
@@ -3,21 +3,12 @@ import 'dart:io';
import '../http/http.dart';
import 'stats.dart';
-/// A variant of an [Angel] server that records performance metrics.
+@deprecated
class AngelMetrics extends Angel {
Angel _inner;
- HttpServer _server;
StreamSubscription _sub;
AngelMetrics() : super() {
- var zoneBuilder = createZoneForRequest;
- createZoneForRequest = (request, req, res) async {
- var spec = await zoneBuilder(request, req, res);
- return new ZoneSpecification.from(
- spec,
- );
- };
-
get('/metrics', (req, res) {
res.contentType = ContentType.HTML;
@@ -63,31 +54,8 @@ class AngelMetrics extends Angel {
});
}
- factory AngelMetrics.custom(ServerGenerator serverGenerator) {
- return new AngelMetrics().._inner = new Angel.custom(serverGenerator);
- }
-
- @override
- HttpServer get httpServer => _server ?? super.httpServer;
-
final AngelMetricsStats stats = new AngelMetricsStats._();
- @override
- Future startServer([address, int port]) async {
- if (_inner == null) return await super.startServer(address, port);
-
- var host = address ?? InternetAddress.LOOPBACK_IP_V4;
- _server = await _inner.serverGenerator(host, port ?? 0);
-
- for (var configurer in startupHooks) {
- await configure(configurer);
- }
-
- optimizeForProduction();
- _sub = _server.listen(handleRequest);
- return _server;
- }
-
@override
Future close() async {
_sub?.cancel();
@@ -95,31 +63,11 @@ class AngelMetrics extends Angel {
return await super.close();
}
- @override
- Future createRequestContext(HttpRequest request) {
- return stats.createRequestContext
- .run(() => super.createRequestContext(request));
- }
-
- @override
- Future createResponseContext(HttpResponse response,
- [RequestContext correspondingRequest]) {
- return stats.createResponseContext.run(
- () => super.createResponseContext(response, correspondingRequest));
- }
-
@override
Iterable resolveAll(String absolute, String relative,
{String method: 'GET', bool strip: true}) {
return stats.resolveAll.run(() =>
- super.resolveAll(absolute, relative, method: method, strip: strip));
- }
-
- @override
- Future handleRequest(HttpRequest request) {
- return stats.handleRequest.run(() async {
- await super.handleRequest(request);
- });
+ _inner.resolveAll(absolute, relative, method: method, strip: strip));
}
@override
@@ -140,37 +88,22 @@ class AngelMetrics extends Angel {
Function handler, RequestContext req, ResponseContext res) {
return stats.runContained.run(() => super.runContained(handler, req, res));
}
-
- @override
- Future sendResponse(
- HttpRequest request, RequestContext req, ResponseContext res,
- {bool ignoreFinalizers: false}) {
- return stats.sendResponse.run(() => super.sendResponse(request, req, res));
- }
}
class AngelMetricsStats {
AngelMetricsStats._() {
all = [
- createRequestContext,
- createResponseContext,
resolveAll,
executeHandler,
getHandlerResult,
runContained,
- sendResponse,
- handleRequest,
];
}
- final Stats createRequestContext = new Stats('createRequestContext');
- final Stats createResponseContext = new Stats('createResponseContext');
final Stats resolveAll = new Stats('resolveAll');
- final Stats handleRequest = new Stats('handleRequest');
final Stats executeHandler = new Stats('executeHandler');
final Stats getHandlerResult = new Stats('getHandlerResult');
final Stats runContained = new Stats('runContained');
- final Stats sendResponse = new Stats('sendResponse');
List all;