diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 00000000..f3e502d1 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/All_Tests.xml b/.idea/runConfigurations/All_Tests.xml new file mode 100644 index 00000000..ac11209e --- /dev/null +++ b/.idea/runConfigurations/All_Tests.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Controller_Tests.xml b/.idea/runConfigurations/Controller_Tests.xml new file mode 100644 index 00000000..16c24846 --- /dev/null +++ b/.idea/runConfigurations/Controller_Tests.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/DI_Tests.xml b/.idea/runConfigurations/DI_Tests.xml new file mode 100644 index 00000000..5c5345d7 --- /dev/null +++ b/.idea/runConfigurations/DI_Tests.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Hooked_Tests.xml b/.idea/runConfigurations/Hooked_Tests.xml new file mode 100644 index 00000000..592565a1 --- /dev/null +++ b/.idea/runConfigurations/Hooked_Tests.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Routing_Tests.xml b/.idea/runConfigurations/Routing_Tests.xml new file mode 100644 index 00000000..3790ba95 --- /dev/null +++ b/.idea/runConfigurations/Routing_Tests.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9bf5a491..b6251cab 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,17 +1,13 @@ - - - + + + - - - - + + - - @@ -32,26 +28,38 @@ - - + + - - + + - - + + - - + + + + + + + + + + + + + + @@ -121,8 +129,11 @@ @@ -320,7 +331,7 @@ 1481236071442 - + 1481237183504 @@ -329,7 +340,14 @@ - \ No newline at end of file diff --git a/lib/src/http/fatal_error.dart b/lib/src/http/fatal_error.dart new file mode 100644 index 00000000..665751d2 --- /dev/null +++ b/lib/src/http/fatal_error.dart @@ -0,0 +1,8 @@ +/// Thrown whenever Angel completely fails to respond to a request. +class AngelFatalError { + var error; + StackTrace stack; + + AngelFatalError({this.error, this.stack}); +} + diff --git a/lib/src/http/response_context.dart b/lib/src/http/response_context.dart index c3e870da..ec7b7d5a 100644 --- a/lib/src/http/response_context.dart +++ b/lib/src/http/response_context.dart @@ -151,7 +151,6 @@ class ResponseContext extends Extensible { // UserController@show List split = action.split("@"); - // Todo: AngelResponseException if (split.length < 2) throw new Exception( "Controller redirects must take the form of 'Controller@action'. You gave: $action"); diff --git a/lib/src/http/server.dart b/lib/src/http/server.dart index 5efb940b..b810b825 100644 --- a/lib/src/http/server.dart +++ b/lib/src/http/server.dart @@ -6,16 +6,15 @@ import 'dart:math' show Random; import 'dart:mirrors'; import 'package:angel_route/angel_route.dart'; import 'package:json_god/json_god.dart' as god; -import 'package:shelf/shelf.dart' as shelf; import 'angel_base.dart'; import 'angel_http_exception.dart'; import 'controller.dart'; +import 'fatal_error.dart'; import 'request_context.dart'; import 'response_context.dart'; import 'routable.dart'; import 'service.dart'; export 'package:container/container.dart'; -part 'server_shelved.dart'; final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)'); @@ -31,10 +30,14 @@ typedef Future AngelConfigurer(AngelBase app); /// A powerful real-time/REST/MVC server class. class Angel extends AngelBase { - var _afterProcessed = new StreamController.broadcast(); - var _beforeProcessed = new StreamController.broadcast(); - var _fatalErrorStream = new StreamController.broadcast(); - var _onController = new StreamController.broadcast(); + StreamController _afterProcessed = + new StreamController.broadcast(); + StreamController _beforeProcessed = + new StreamController.broadcast(); + StreamController _fatalErrorStream = + new StreamController.broadcast(); + StreamController _onController = + new StreamController.broadcast(); final Random _rand = new Random.secure(); ServerGenerator _serverGenerator = HttpServer.bind; @@ -46,7 +49,7 @@ class Angel extends AngelBase { Stream get beforeProcessed => _beforeProcessed.stream; /// Fired on fatal errors. - Stream get fatalErrorStream => _fatalErrorStream.stream; + Stream get fatalErrorStream => _fatalErrorStream.stream; /// Fired whenever a controller is added to this instance. /// @@ -80,8 +83,8 @@ class Angel extends AngelBase { HttpServer httpServer; /// Handles a server error. - _onError(e, [StackTrace stackTrace]) { - _fatalErrorStream.add({"error": e, "stack": stackTrace}); + _onError(e, [StackTrace st]) { + _fatalErrorStream.add(new AngelFatalError(error: e, stack: st)); } void _printDebug(x) { @@ -231,11 +234,9 @@ class Angel extends AngelBase { await _errorHandler(e, req, res); } _finalizeResponse(request, res); - } catch (_) { - // Todo: This exception needs to be caught as well. + } catch (e, st) { + _fatalErrorStream.add(new AngelFatalError(error: e, stack: st)); } - } else { - // Todo: Uncaught exceptions need to be... Caught. } _onError(e, st); diff --git a/lib/src/http/server_shelved.dart b/lib/src/http/server_shelved.dart deleted file mode 100644 index 0f7c77a3..00000000 --- a/lib/src/http/server_shelved.dart +++ /dev/null @@ -1,19 +0,0 @@ -part of angel_framework.http.server; - - -// Todo: Shelf interop -class ShelvedAngel extends Angel { - shelf.Pipeline pipeline = new shelf.Pipeline(); - - ShelvedAngel({bool debug: false}) : super(debug: debug) {} - - @override - Future startServer([InternetAddress address, int port]) async { - /* final handler = pipeline.addHandler((shelf.Request req) { - // io.handleRequest() - });*/ - - return await super.startServer(address, port); - } - -} diff --git a/pubspec.yaml b/pubspec.yaml index dacc6765..7f06ce29 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,6 @@ dependencies: json_god: ^2.0.0-beta merge_map: ^1.0.0 mime: ^0.9.3 - shelf: ^0.6.7 dev_dependencies: http: ^0.11.3 test: ^0.12.13