Fixed todo

This commit is contained in:
thosakwe 2016-12-10 09:12:07 -05:00
parent 9047890f52
commit 5312d353f2
12 changed files with 155 additions and 68 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="ECMAScript 6" />
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All Tests" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true">
<option name="filePath" value="$PROJECT_DIR$/test" />
<option name="scope" value="FOLDER" />
<method />
</configuration>
</component>

View file

@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Controller Tests" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true">
<option name="filePath" value="$PROJECT_DIR$/test/controller_test.dart" />
<method />
</configuration>
</component>

View file

@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="DI Tests" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true">
<option name="filePath" value="$PROJECT_DIR$/test/di.dart" />
<method />
</configuration>
</component>

View file

@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Hooked Tests" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true">
<option name="filePath" value="$PROJECT_DIR$/test/hooked_test.dart" />
<method />
</configuration>
</component>

View file

@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Routing Tests" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true">
<option name="filePath" value="$PROJECT_DIR$/test/routing_test.dart" />
<method />
</configuration>
</component>

View file

@ -1,17 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="Core done?">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" afterPath="$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/modules.xml" afterPath="$PROJECT_DIR$/.idea/modules.xml" />
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lib/src/http/fatal_error.dart" />
<change type="DELETED" beforePath="$PROJECT_DIR$/lib/src/http/server_shelved.dart" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/README.md" afterPath="$PROJECT_DIR$/README.md" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/hooked_service.dart" afterPath="$PROJECT_DIR$/lib/src/http/hooked_service.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/metadata.dart" afterPath="$PROJECT_DIR$/lib/src/http/metadata.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/routable.dart" afterPath="$PROJECT_DIR$/lib/src/http/routable.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/response_context.dart" afterPath="$PROJECT_DIR$/lib/src/http/response_context.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/server.dart" afterPath="$PROJECT_DIR$/lib/src/http/server.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/pubspec.yaml" afterPath="$PROJECT_DIR$/pubspec.yaml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/test/common.dart" afterPath="$PROJECT_DIR$/test/common.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/test/hooked_test.dart" afterPath="$PROJECT_DIR$/test/hooked_test.dart" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
@ -32,26 +28,38 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="pubspec.yaml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<file leaf-file-name="hooked_service.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/hooked_service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="14" lean-forward="false" selection-start-line="6" selection-start-column="14" selection-end-line="6" selection-end-column="14" />
<state relative-caret-position="675">
<caret line="49" column="5" lean-forward="false" selection-start-line="49" selection-start-column="5" selection-end-line="49" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="hooked_service.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/src/http/hooked_service.dart">
<file leaf-file-name="response_context.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/src/http/response_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="49" column="5" lean-forward="false" selection-start-line="49" selection-start-column="5" selection-end-line="49" selection-end-column="5" />
<state relative-caret-position="230">
<caret line="153" column="25" lean-forward="true" selection-start-line="153" selection-start-column="25" selection-end-line="153" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="server.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="335">
<caret line="236" column="27" lean-forward="false" selection-start-line="236" selection-start-column="27" selection-end-line="236" selection-end-column="27" />
<folding>
<element signature="e#38#58#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="routable.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/routable.dart">
<provider selected="true" editor-type-id="text-editor">
@ -121,8 +129,11 @@
<option value="$PROJECT_DIR$/test/common.dart" />
<option value="$PROJECT_DIR$/test/hooked_test.dart" />
<option value="$PROJECT_DIR$/lib/src/http/hooked_service.dart" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/http/fatal_error.dart" />
<option value="$PROJECT_DIR$/lib/src/http/server.dart" />
<option value="$PROJECT_DIR$/lib/src/http/response_context.dart" />
</list>
</option>
</component>
@ -320,7 +331,7 @@
<updated>1481236071442</updated>
<workItem from="1481236073268" duration="1150000" />
<workItem from="1481238230885" duration="38000" />
<workItem from="1481377809918" duration="884000" />
<workItem from="1481377809918" duration="1265000" />
</task>
<task id="LOCAL-00001" summary="Re-designed exception">
<created>1481237183504</created>
@ -329,7 +340,14 @@
<option name="project" value="LOCAL" />
<updated>1481237183504</updated>
</task>
<option name="localTasksCounter" value="2" />
<task id="LOCAL-00002" summary="Core done?">
<created>1481378740441</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1481378740441</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers />
</component>
<component name="TestHistory">
@ -365,21 +383,31 @@
</history-entry>
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="2072000" />
<option name="totallyTimeSpent" value="2453000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true" />
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="241" y="49" width="1621" height="830" extended-state="0" />
<editor active="false" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3292683" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Tool Output" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32791328" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32791328" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Dart Analysis" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32843137" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3292683" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32843137" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2125" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="ANTLR Preview" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
@ -389,7 +417,6 @@
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
@ -505,14 +532,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="14" lean-forward="false" selection-start-line="6" selection-start-column="14" selection-end-line="6" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
@ -524,13 +543,55 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/server_shelved.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="3" lean-forward="false" selection-start-line="3" selection-start-column="3" selection-end-line="3" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="13" column="14" lean-forward="false" selection-start-line="13" selection-start-column="14" selection-end-line="13" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/hooked_service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<state relative-caret-position="675">
<caret line="49" column="5" lean-forward="false" selection-start-line="49" selection-start-column="5" selection-end-line="49" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/fatal_error.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="67" lean-forward="false" selection-start-line="0" selection-start-column="67" selection-end-line="0" selection-end-column="67" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="335">
<caret line="236" column="27" lean-forward="false" selection-start-line="236" selection-start-column="27" selection-end-line="236" selection-end-column="27" />
<folding>
<element signature="e#38#58#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/response_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="230">
<caret line="153" column="25" lean-forward="true" selection-start-line="153" selection-start-column="25" selection-end-line="153" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
</component>
</project>

View file

@ -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});
}

View file

@ -151,7 +151,6 @@ class ResponseContext extends Extensible {
// UserController@show
List<String> split = action.split("@");
// Todo: AngelResponseException
if (split.length < 2)
throw new Exception(
"Controller redirects must take the form of 'Controller@action'. You gave: $action");

View file

@ -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<HttpRequest>.broadcast();
var _beforeProcessed = new StreamController<HttpRequest>.broadcast();
var _fatalErrorStream = new StreamController<Map>.broadcast();
var _onController = new StreamController<Controller>.broadcast();
StreamController<HttpRequest> _afterProcessed =
new StreamController<HttpRequest>.broadcast();
StreamController<HttpRequest> _beforeProcessed =
new StreamController<HttpRequest>.broadcast();
StreamController<AngelFatalError> _fatalErrorStream =
new StreamController<AngelFatalError>.broadcast();
StreamController<Controller> _onController =
new StreamController<Controller>.broadcast();
final Random _rand = new Random.secure();
ServerGenerator _serverGenerator = HttpServer.bind;
@ -46,7 +49,7 @@ class Angel extends AngelBase {
Stream<HttpRequest> get beforeProcessed => _beforeProcessed.stream;
/// Fired on fatal errors.
Stream<Map> get fatalErrorStream => _fatalErrorStream.stream;
Stream<AngelFatalError> 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);

View file

@ -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<HttpServer> startServer([InternetAddress address, int port]) async {
/* final handler = pipeline.addHandler((shelf.Request req) {
// io.handleRequest()
});*/
return await super.startServer(address, port);
}
}

View file

@ -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