diff --git a/lib/src/http/http.dart b/lib/src/http/http.dart index f8300ab1..44c163e1 100644 --- a/lib/src/http/http.dart +++ b/lib/src/http/http.dart @@ -7,7 +7,7 @@ import 'dart:io'; import 'dart:math'; import 'dart:mirrors'; import 'package:body_parser/body_parser.dart'; -import 'package:json_god/json_god.dart'; +import 'package:json_god/json_god.dart' as god; import 'package:merge_map/merge_map.dart'; import 'package:mime/mime.dart'; @@ -21,4 +21,4 @@ part 'routable.dart'; part 'server.dart'; part 'service.dart'; part 'service_hooked.dart'; -part 'services/memory.dart'; \ No newline at end of file +part 'services/memory.dart'; diff --git a/lib/src/http/server.dart b/lib/src/http/server.dart index 8ec42c0f..87c56e7c 100644 --- a/lib/src/http/server.dart +++ b/lib/src/http/server.dart @@ -4,8 +4,8 @@ part of angel_framework.http; typedef Future ServerGenerator(InternetAddress address, int port); /// Handles an [AngelHttpException]. -typedef Future AngelErrorHandler(AngelHttpException err, RequestContext req, - ResponseContext res); +typedef Future AngelErrorHandler( + AngelHttpException err, RequestContext req, ResponseContext res); /// A function that configures an [Angel] server in some way. typedef Future AngelConfigurer(Angel app); @@ -38,18 +38,16 @@ class Angel extends Routable { List after = []; HttpServer httpServer; - God god = new God(); startServer(InternetAddress address, int port) async { var server = - await _serverGenerator(address ?? InternetAddress.LOOPBACK_IP_V4, port); + await _serverGenerator(address ?? InternetAddress.LOOPBACK_IP_V4, port); this.httpServer = server; server.listen((HttpRequest request) async { - String req_url = request.uri.toString().replaceAll( - new RegExp(r'\/+$'), ''); - if (req_url.isEmpty) - req_url = '/'; + String req_url = + request.uri.toString().replaceAll(new RegExp(r'\/+$'), ''); + if (req_url.isEmpty) req_url = '/'; RequestContext req = await RequestContext.from(request, {}, this, null); ResponseContext res = await ResponseContext.from(request.response, this); @@ -109,8 +107,8 @@ class Angel extends Routable { return server; } - Future _applyHandler(handler, RequestContext req, - ResponseContext res) async { + Future _applyHandler( + handler, RequestContext req, ResponseContext res) async { if (handler is RequestMiddleware) { var result = await handler(req, res); if (result is bool) @@ -191,8 +189,8 @@ class Angel extends Routable { if (routable is Service) { routable.app = this; } - super.use( - path, routable, hooked: hooked, middlewareNamespace: middlewareNamespace); + super.use(path, routable, + hooked: hooked, middlewareNamespace: middlewareNamespace); } onError(handler) { @@ -205,27 +203,18 @@ class Angel extends Routable { if (stackTrace != null) stderr.write(stackTrace.toString()); } - Angel - () - : - super() {} + Angel() : super() {} /// Creates an HTTPS server. /// 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. - Angel.secure - (String certificateChainPath, String - serverKeyPath - , - { - String password - }) - : super() - { + Angel.secure(String certificateChainPath, String serverKeyPath, + {String password}) + : super() { _serverGenerator = (InternetAddress address, int port) async { var certificateChain = - Platform.script.resolve('server_chain.pem').toFilePath(); + Platform.script.resolve('server_chain.pem').toFilePath(); var serverKey = Platform.script.resolve('server_key.pem').toFilePath(); var serverContext = new SecurityContext(); serverContext.useCertificateChain(certificateChain); diff --git a/pubspec.yaml b/pubspec.yaml index c8bc52de..03f5eb73 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,10 +4,10 @@ description: Core libraries for the Angel framework. author: Tobe O homepage: https://github.com/angel-dart/angel_framework dependencies: - body_parser: ^1.0.0-dev - json_god: ^1.0.0 - merge_map: ^1.0.0 - mime: ^0.9.3 + body_parser: ">=1.0.0-dev <2.0.0" + json_god: ">=2.0.0-beta <3.0.0" + merge_map: ">=1.0.0 <2.0.0" + mime: ">=0.9.3 <1.0.0" dev_dependencies: - http: ^0.11.3 - test: ^0.12.13 \ No newline at end of file + http: ">= 0.11.3 < 0.12.0" + test: ">= 0.12.13 < 0.13.0" \ No newline at end of file