diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2d3d8bfd..cbf873ad 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,6 +3,9 @@
+
+
+
@@ -25,16 +28,26 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -47,12 +60,10 @@
-
-
+
+
-
-
@@ -183,7 +194,6 @@
-
@@ -205,9 +215,10 @@
-
+
+
@@ -617,14 +628,7 @@
-
-
-
- 1493088262571
-
-
-
- 1493088262571
+
1493090378709
@@ -962,7 +966,14 @@
1517976712783
-
+
+ 1517976806435
+
+
+
+ 1517976806435
+
+
@@ -998,7 +1009,7 @@
-
+
@@ -1057,7 +1068,6 @@
-
@@ -1082,11 +1092,12 @@
-
+
+
-
+
@@ -1194,13 +1205,6 @@
-
-
-
-
-
-
-
@@ -1222,13 +1226,6 @@
-
-
-
-
-
-
-
@@ -1392,17 +1389,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -1456,25 +1442,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14fdff46..76dca643 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
* `ResponseContext` no longer automatically closes if `serializer` returns an
empty string.
* Added `autoSnakeCaseNames` to `MapService`.
+* Deprecated `Angel.createZoneForRequest`.
+* Deprecated all `Angel` methods that directly touch an `HttpServer` or `HttpRequest`.
+* Created the `AngelHttp` class.
# 1.1.0+3
* Modified `ResponseContext#isOpen` to also return `false` if streaming is being used.
diff --git a/lib/src/http/angel_http.dart b/lib/src/http/angel_http.dart
index 605a7bba..5579d0d1 100644
--- a/lib/src/http/angel_http.dart
+++ b/lib/src/http/angel_http.dart
@@ -18,15 +18,19 @@ class AngelHttp {
final Angel app;
bool _closed = false;
HttpServer _server;
- Future Function(dynamic,int) _serverGenerator = HttpServer.bind;
+ Future Function(dynamic, int) _serverGenerator = HttpServer.bind;
StreamSubscription _sub;
Pool _pool;
AngelHttp(this.app);
+ /// The function used to bind this instance to an HTTP server.
+ Future Function(dynamic, int) get serverGenerator => _serverGenerator;
+
/// An instance mounted on a server started by the [serverGenerator].
- factory AngelHttp.custom(Angel app, ServerGenerator serverGenerator) {
+ factory AngelHttp.custom(
+ Angel app, Future Function(dynamic, int) serverGenerator) {
return new AngelHttp(app).._serverGenerator = serverGenerator;
}
@@ -45,10 +49,11 @@ class AngelHttp {
/// Provide paths to a certificate chain and server key (both .pem).
/// If no password is provided, a random one will be generated upon running
/// the server.
- factory AngelHttp.secure(Angel app, String certificateChainPath, String serverKeyPath,
+ factory AngelHttp.secure(
+ Angel app, String certificateChainPath, String serverKeyPath,
{bool debug: false, String password}) {
var certificateChain =
- Platform.script.resolve(certificateChainPath).toFilePath();
+ Platform.script.resolve(certificateChainPath).toFilePath();
var serverKey = Platform.script.resolve(serverKeyPath).toFilePath();
var serverContext = new SecurityContext();
serverContext.useCertificateChain(certificateChain, password: password);
@@ -99,7 +104,7 @@ class AngelHttp {
Tuple3>> resolveTuple() {
Router r = app.optimizedRouter;
var resolved =
- r.resolveAbsolute(path, method: req.method, strip: false);
+ r.resolveAbsolute(path, method: req.method, strip: false);
return new Tuple3(
new MiddlewarePipeline(resolved).handlers,
@@ -203,7 +208,7 @@ class AngelHttp {
Future finalizers = ignoreFinalizers == true
? new Future.value()
: app.responseFinalizers.fold(
- new Future.value(), (out, f) => out.then((_) => f(req, res)));
+ new Future.value(), (out, f) => out.then((_) => f(req, res)));
if (res.isOpen) res.end();
@@ -218,7 +223,7 @@ class AngelHttp {
if (res.encoders.isNotEmpty) {
var allowedEncodings =
- req.headers[HttpHeaders.ACCEPT_ENCODING]?.map((str) {
+ req.headers[HttpHeaders.ACCEPT_ENCODING]?.map((str) {
// Ignore quality specifications in accept-encoding
// ex. gzip;q=0.8
if (!str.contains(';')) return str;
@@ -281,7 +286,7 @@ class AngelHttp {
}
Future createResponseContext(HttpResponse response,
- [RequestContext correspondingRequest]) =>
+ [RequestContext correspondingRequest]) =>
new Future.value(
new ResponseContext(response, app, correspondingRequest)
..serializer = (app.serializer ?? god.serialize)
@@ -294,4 +299,4 @@ class AngelHttp {
void throttle(int maxConcurrentRequests, {Duration timeout}) {
_pool = new Pool(maxConcurrentRequests, timeout: timeout);
}
-}
\ No newline at end of file
+}
diff --git a/lib/src/http/http.dart b/lib/src/http/http.dart
index f72ebdc0..a1f09d06 100644
--- a/lib/src/http/http.dart
+++ b/lib/src/http/http.dart
@@ -3,7 +3,6 @@ library angel_framework.http;
import 'dart:async';
import 'dart:io';
-import 'server.dart' show ServerGenerator;
export 'package:angel_http_exception/angel_http_exception.dart';
export 'package:angel_model/angel_model.dart';
export 'package:angel_route/angel_route.dart';
@@ -25,8 +24,7 @@ export 'typed_service.dart';
Future startShared(address, int port) => HttpServer
.bind(address ?? InternetAddress.LOOPBACK_IP_V4, port ?? 0, shared: true);
-/// Boots a secure shared server instance. Use this if launching multiple isolates
-ServerGenerator startSharedSecure(SecurityContext securityContext) {
+Future Function(dynamic, int) startSharedSecure(SecurityContext securityContext) {
return (address, int port) => HttpServer.bindSecure(
address ?? InternetAddress.LOOPBACK_IP_V4, port ?? 0, securityContext,
shared: true);
diff --git a/lib/src/http/server.dart b/lib/src/http/server.dart
index 9492b945..1316299f 100644
--- a/lib/src/http/server.dart
+++ b/lib/src/http/server.dart
@@ -22,6 +22,9 @@ import 'service.dart';
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
/// A function that binds an [Angel] server to an Internet address and port.
+///
+/// Prefer the Future Function(dynamic, int) syntax.
+@deprecated
typedef Future ServerGenerator(address, int port);
/// A function that configures an [Angel] server in some way.
@@ -37,7 +40,7 @@ class Angel extends AngelBase {
AngelHttp _http;
bool _isProduction;
Angel _parent;
- ServerGenerator _serverGenerator = HttpServer.bind;
+ Future Function(dynamic, int) _serverGenerator = HttpServer.bind;
/// A global Map of converters that can transform responses bodies.
final Map, List>> encoders = {};
@@ -85,8 +88,9 @@ class Angel extends AngelBase {
(Platform.environment['ANGEL_ENV'] == 'production');
}
- /// The function used to bind this instance to an HTTP server.
- ServerGenerator get serverGenerator => _serverGenerator;
+ /// Use the serving methods in [AngelHttp] instead.
+ @deprecated
+ ServerGenerator get serverGenerator => _http.serverGenerator;
/// Returns the parent instance of this application, if any.
Angel get parent => _parent;
@@ -497,7 +501,7 @@ class Angel extends AngelBase {
/// Use the serving methods in [AngelHttp] instead.
@deprecated
- factory Angel.custom(ServerGenerator serverGenerator) {
+ factory Angel.custom(Future Function(dynamic, int) serverGenerator) {
var app = new Angel();
return app.._http = new AngelHttp.custom(app, serverGenerator);
}