Remove Angel.inject

This commit is contained in:
Tobe O 2018-08-20 15:43:27 -04:00
parent e576fc5b50
commit 8739dbe4f7
3 changed files with 105 additions and 57 deletions

View file

@ -4,7 +4,7 @@
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment=""> <list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" /> <change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/core/request_context.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/core/request_context.dart" afterDir="false" /> <change beforePath="$PROJECT_DIR$/lib/src/core/server.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/core/server.dart" afterDir="false" />
</list> </list>
<ignored path="$PROJECT_DIR$/.tmp/" /> <ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" /> <ignored path="$PROJECT_DIR$/temp/" />
@ -42,19 +42,19 @@
<file leaf-file-name="routing_test.dart" pinned="false" current-in-tab="false"> <file leaf-file-name="routing_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/routing_test.dart"> <entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192"> <state relative-caret-position="352">
<caret line="20" column="1" selection-start-line="20" selection-start-column="1" selection-end-line="20" selection-end-column="1" /> <caret line="30" column="17" lean-forward="true" selection-start-line="30" selection-start-column="17" selection-end-line="30" selection-end-column="17" />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="http_request_context.dart" pinned="false" current-in-tab="false"> <file leaf-file-name="server.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/http_request_context.dart"> <entry file="file://$PROJECT_DIR$/lib/src/core/server.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16"> <state relative-caret-position="156">
<caret line="9" column="42" selection-start-line="9" selection-start-column="42" selection-end-line="9" selection-end-column="42" /> <caret line="250" column="3" lean-forward="true" selection-start-line="250" selection-start-column="3" selection-end-line="250" selection-end-column="3" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#38#58#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -64,8 +64,8 @@
<entry file="file://$PROJECT_DIR$/CHANGELOG.md"> <entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor relative-caret-position="544"> <first_editor relative-caret-position="556">
<caret line="31" column="60" selection-start-line="31" selection-start-column="60" selection-end-line="31" selection-end-column="60" /> <caret line="32" column="25" selection-start-line="32" selection-start-column="25" selection-end-line="32" selection-end-column="25" />
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>
@ -117,7 +117,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>as Map&lt;String, dynamic&gt;</find>
<find>result as Map&lt;String, dynamic&gt;</find> <find>result as Map&lt;String, dynamic&gt;</find>
<find>random_strin</find> <find>random_strin</find>
<find>Angel()</find> <find>Angel()</find>
@ -147,6 +146,7 @@
<find>origina</find> <find>origina</find>
<find>originalBuffer</find> <find>originalBuffer</find>
<find>lazyQue</find> <find>lazyQue</find>
<find>injections</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>useStream</replace> <replace>useStream</replace>
@ -246,12 +246,12 @@
<option value="$PROJECT_DIR$/performance/hello/main.dart" /> <option value="$PROJECT_DIR$/performance/hello/main.dart" />
<option value="$PROJECT_DIR$/test/parameter_meta_test.dart" /> <option value="$PROJECT_DIR$/test/parameter_meta_test.dart" />
<option value="$PROJECT_DIR$/lib/src/http/http_request_context.dart" /> <option value="$PROJECT_DIR$/lib/src/http/http_request_context.dart" />
<option value="$PROJECT_DIR$/lib/src/core/server.dart" />
<option value="$PROJECT_DIR$/lib/src/core/service.dart" /> <option value="$PROJECT_DIR$/lib/src/core/service.dart" />
<option value="$PROJECT_DIR$/example/main.dart" /> <option value="$PROJECT_DIR$/example/main.dart" />
<option value="$PROJECT_DIR$/test/routing_test.dart" /> <option value="$PROJECT_DIR$/test/routing_test.dart" />
<option value="$PROJECT_DIR$/lib/src/core/metadata.dart" /> <option value="$PROJECT_DIR$/lib/src/core/metadata.dart" />
<option value="$PROJECT_DIR$/lib/src/core/request_context.dart" /> <option value="$PROJECT_DIR$/lib/src/core/request_context.dart" />
<option value="$PROJECT_DIR$/lib/src/core/server.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" /> <option value="$PROJECT_DIR$/CHANGELOG.md" />
</list> </list>
</option> </option>
@ -275,10 +275,65 @@
<ConfirmationsSetting value="2" id="Add" /> <ConfirmationsSetting value="2" id="Add" />
</component> </component>
<component name="ProjectView"> <component name="ProjectView">
<navigator proportions="" version="1"> <navigator currentView="Scope" currentSubView="Project Files" proportions="" version="1">
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes /> <panes>
<pane id="PackagesPane" />
<pane id="AndroidView" />
<pane id="ProjectPane" />
<pane id="Scope">
<subPane subId="Project Files">
<expand>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="example" type="cbb8eebc:String" user="example" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="lib" type="cbb8eebc:String" user="lib" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="lib" type="cbb8eebc:String" user="lib" />
<item name="src" type="cbb8eebc:String" user="src" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="lib" type="cbb8eebc:String" user="lib" />
<item name="src" type="cbb8eebc:String" user="src" />
<item name="core" type="cbb8eebc:String" user="core" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="lib" type="cbb8eebc:String" user="lib" />
<item name="src" type="cbb8eebc:String" user="src" />
<item name="http" type="cbb8eebc:String" user="http" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="test" type="cbb8eebc:String" user="test" />
</path>
<path>
<item name="Root" type="cbb8eebc:String" user="Root" />
<item name="framework" type="cbb8eebc:String" user="framework" />
<item name="tool" type="cbb8eebc:String" user="tool" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="GO_FMT" value="false" /> <property name="GO_FMT" value="false" />
@ -617,14 +672,7 @@
<workItem from="1534009494986" duration="594000" /> <workItem from="1534009494986" duration="594000" />
<workItem from="1534546784803" duration="353000" /> <workItem from="1534546784803" duration="353000" />
<workItem from="1534547885788" duration="9908000" /> <workItem from="1534547885788" duration="9908000" />
<workItem from="1534793956753" duration="160000" /> <workItem from="1534793956753" duration="220000" />
</task>
<task id="LOCAL-00091" summary="+7">
<created>1530124843110</created>
<option name="number" value="00091" />
<option name="presentableId" value="LOCAL-00091" />
<option name="project" value="LOCAL" />
<updated>1530124843111</updated>
</task> </task>
<task id="LOCAL-00092" summary="Provide custom IsInstanceOf for testing"> <task id="LOCAL-00092" summary="Provide custom IsInstanceOf for testing">
<created>1531146512450</created> <created>1531146512450</created>
@ -962,7 +1010,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1534738209023</updated> <updated>1534738209023</updated>
</task> </task>
<option name="localTasksCounter" value="140" /> <task id="LOCAL-00140" summary="Remove req.injections">
<created>1534794125343</created>
<option name="number" value="00140" />
<option name="presentableId" value="LOCAL-00140" />
<option name="project" value="LOCAL" />
<updated>1534794125343</updated>
</task>
<option name="localTasksCounter" value="141" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
@ -998,7 +1053,7 @@
</history-entry> </history-entry>
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="172367000" /> <option name="totallyTimeSpent" value="172427000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -1035,7 +1090,7 @@
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32905984" /> <window_info anchor="bottom" id="Version Control" order="7" weight="0.32905984" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.4964476" weight="0.3973799" /> <window_info anchor="bottom" id="Run" order="2" sideWeight="0.4964476" weight="0.3973799" />
<window_info anchor="bottom" id="Terminal" order="7" weight="0.44978166" /> <window_info anchor="bottom" id="Terminal" order="7" weight="0.44978166" />
<window_info content_ui="combo" id="Project" order="0" weight="0.27920645" /> <window_info content_ui="combo" id="Project" order="0" weight="0.27876106" />
<window_info anchor="right" id="SciView" order="4" /> <window_info anchor="right" id="SciView" order="4" />
<window_info anchor="right" id="Theme Preview" order="3" /> <window_info anchor="right" id="Theme Preview" order="3" />
<window_info id="Favorites" order="3" side_tool="true" /> <window_info id="Favorites" order="3" side_tool="true" />
@ -1061,7 +1116,6 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value="Strip out json god" />
<MESSAGE value="Remove traces of json_god" /> <MESSAGE value="Remove traces of json_god" />
<MESSAGE value="Remove lib/hooks.dart" /> <MESSAGE value="Remove lib/hooks.dart" />
<MESSAGE value="Remove lib/common.dart" /> <MESSAGE value="Remove lib/common.dart" />
@ -1086,7 +1140,8 @@
<MESSAGE value="Rename body parsing methods" /> <MESSAGE value="Rename body parsing methods" />
<MESSAGE value="Update query parsing" /> <MESSAGE value="Update query parsing" />
<MESSAGE value="Update CHANGELOG" /> <MESSAGE value="Update CHANGELOG" />
<option name="LAST_COMMIT_MESSAGE" value="Update CHANGELOG" /> <MESSAGE value="Remove req.injections" />
<option name="LAST_COMMIT_MESSAGE" value="Remove req.injections" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
@ -1332,13 +1387,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-5">
<caret line="55" column="71" lean-forward="true" selection-start-line="55" selection-start-column="71" selection-end-line="55" selection-end-column="71" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart"> <entry file="file://$PROJECT_DIR$/lib/src/core/response_context.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="5223"> <state relative-caret-position="5223">
@ -1367,13 +1415,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="20" column="1" selection-start-line="20" selection-start-column="1" selection-end-line="20" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/service.dart"> <entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3216"> <state relative-caret-position="3216">
@ -1413,19 +1454,36 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/http_request_context.dart"> <entry file="file://$PROJECT_DIR$/lib/src/http/http_request_context.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16"> <state relative-caret-position="183">
<caret line="9" column="42" selection-start-line="9" selection-start-column="42" selection-end-line="9" selection-end-column="42" /> <caret line="13" lean-forward="true" selection-start-line="13" selection-end-line="13" />
<folding> <folding>
<element signature="e#0#20#0" expanded="true" /> <element signature="e#0#20#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/test/routing_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
<caret line="30" column="17" lean-forward="true" selection-start-line="30" selection-start-column="17" selection-end-line="30" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="156">
<caret line="250" column="3" lean-forward="true" selection-start-line="250" selection-start-column="3" selection-end-line="250" selection-end-column="3" />
<folding>
<element signature="e#38#58#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CHANGELOG.md"> <entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor relative-caret-position="544"> <first_editor relative-caret-position="556">
<caret line="31" column="60" selection-start-line="31" selection-start-column="60" selection-end-line="31" selection-end-column="60" /> <caret line="32" column="25" selection-start-line="32" selection-start-column="25" selection-end-line="32" selection-end-column="25" />
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>

View file

@ -29,4 +29,5 @@ with `Angel.eagerParseRequestBodies`.
replaced with `parseBody`, `parseUploadedFiles`, and `parseRawRequestBuffer`, respectively. replaced with `parseBody`, `parseUploadedFiles`, and `parseRawRequestBuffer`, respectively.
* Removed the synchronous equivalents of the above methods (`body`, `files`, and `originalBuffer`), * Removed the synchronous equivalents of the above methods (`body`, `files`, and `originalBuffer`),
as well as `query`. as well as `query`.
* Remove `Angel.injections` and `RequestContext.injections`. * Removed `Angel.injections` and `RequestContext.injections`.
* Removed `Angel.inject`.

View file

@ -45,8 +45,6 @@ class Angel extends Routable {
/// A global Map of converters that can transform responses bodies. /// A global Map of converters that can transform responses bodies.
final Map<String, Converter<List<int>, List<int>>> encoders = {}; final Map<String, Converter<List<int>, List<int>>> encoders = {};
final Map _injections = {};
/// A function that is called on every request to create a [Zone], A.K.A an asynchronous /// A function that is called on every request to create a [Zone], A.K.A an asynchronous
/// execution context. /// execution context.
/// ///
@ -113,9 +111,6 @@ class Angel extends Routable {
/// These will only not run if a response's `willCloseItself` is set to `true`. /// These will only not run if a response's `willCloseItself` is set to `true`.
final List<RequestHandler> responseFinalizers = []; final List<RequestHandler> responseFinalizers = [];
/// All global dependencies injected into the application.
Map get injections => _injections;
Container _container; Container _container;
/// A [Map] of application-specific data that can be accessed by any /// A [Map] of application-specific data that can be accessed by any
@ -213,7 +208,6 @@ class Angel extends Routable {
viewGenerator = noViewEngineConfigured; viewGenerator = noViewEngineConfigured;
_preContained.clear(); _preContained.clear();
handlerCache.clear(); handlerCache.clear();
_injections.clear();
encoders.clear(); encoders.clear();
//_serializer = json.encode; //_serializer = json.encode;
_children.clear(); _children.clear();
@ -256,11 +250,6 @@ class Angel extends Routable {
} }
} }
/// Shortcut for adding a middleware to inject a key/value pair on every request.
void inject(key, value) {
_injections[key] = value;
}
/// Shortcuts for adding converters to transform the response buffer/stream of any request. /// Shortcuts for adding converters to transform the response buffer/stream of any request.
void injectEncoders(Map<String, Converter<List<int>, List<int>>> encoders) { void injectEncoders(Map<String, Converter<List<int>, List<int>>> encoders) {
this.encoders.addAll(encoders); this.encoders.addAll(encoders);