waterfall -> chain

This commit is contained in:
Tobe O 2018-09-12 00:17:50 -04:00
parent 9945884b5a
commit ce45ef47e5
3 changed files with 165 additions and 97 deletions

View file

@ -1,10 +1,7 @@
<?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="">
<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" />
</list>
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="" />
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
<ignored path="$PROJECT_DIR$/tmp/" />
@ -29,7 +26,7 @@
<file leaf-file-name="services_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/services_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="368">
<state relative-caret-position="16">
<caret line="23" column="29" selection-start-line="23" selection-start-column="29" selection-end-line="23" selection-end-column="29" />
<folding>
<element signature="e#0#46#0" expanded="true" />
@ -38,32 +35,44 @@
</provider>
</entry>
</file>
<file leaf-file-name="hooked_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/hooked_test.dart">
<file leaf-file-name="service.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="416">
<caret line="125" column="48" lean-forward="true" selection-start-line="125" selection-start-column="48" selection-end-line="125" selection-end-column="48" />
<state relative-caret-position="358">
<caret line="191" column="33" lean-forward="true" selection-start-line="191" selection-start-column="33" selection-end-line="191" selection-end-column="33" />
<folding>
<element signature="e#39#59#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="anonymous_service.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/core/anonymous_service.dart">
<file leaf-file-name="request_context.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/core/request_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="13" column="2" selection-start-line="13" selection-start-column="2" selection-end-line="13" selection-end-column="2" />
<state relative-caret-position="464">
<caret line="29" column="29" selection-start-line="29" selection-start-column="29" selection-end-line="29" selection-end-column="29" />
<folding>
<element signature="e#47#67#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="CHANGELOG.md" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="80">
<caret line="5" column="66" selection-start-line="5" selection-start-column="66" selection-end-line="5" selection-end-column="66" />
</first_editor>
<second_editor />
<file leaf-file-name="pubspec.yaml" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="159">
<caret line="10" column="12" lean-forward="true" selection-start-line="10" selection-start-column="12" selection-end-line="10" selection-end-column="12" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="precontained_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/precontained_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="160">
<caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" />
</state>
</provider>
</entry>
@ -113,8 +122,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>stopw</find>
<find>release</find>
<find>handleRe</find>
<find>get container</find>
<find>Parameter</find>
@ -143,6 +150,8 @@
<find>complet</find>
<find>parseI</find>
<find>read(</find>
<find>as</find>
<find>serviceP</find>
</findStrings>
<replaceStrings>
<replace>FutureOr</replace>
@ -181,10 +190,10 @@
<dir>C:\Users\thosa\Source\Angel\framework\lib\src\http</dir>
<dir>C:\Users\thosa\Source\Angel\framework\test</dir>
<dir>$PROJECT_DIR$/lib/src</dir>
<dir>$PROJECT_DIR$/lib/src/core</dir>
<dir>$PROJECT_DIR$/lib</dir>
<dir>$PROJECT_DIR$/test</dir>
<dir>$PROJECT_DIR$</dir>
<dir>$PROJECT_DIR$/lib/src/core</dir>
</dirStrings>
</component>
<component name="Git.Settings">
@ -237,7 +246,6 @@
<option value="$PROJECT_DIR$/lib/src/http/http_response_context.dart" />
<option value="$PROJECT_DIR$/test/streaming_test.dart" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/core/request_context.dart" />
<option value="$PROJECT_DIR$/lib/src/core/anonymous_service.dart" />
<option value="$PROJECT_DIR$/lib/src/core/service.dart" />
@ -249,6 +257,7 @@
<option value="$PROJECT_DIR$/lib/src/core/core.dart" />
<option value="$PROJECT_DIR$/test/hooked_test.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
</list>
</option>
</component>
@ -277,10 +286,60 @@
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<navigator currentView="Scope" currentSubView="Project Files" proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes />
<panes>
<pane id="AndroidView" />
<pane id="ProjectPane" />
<pane id="PackagesPane" />
<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>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="GO_FMT" value="false" />
@ -627,14 +686,7 @@
<workItem from="1534863259966" duration="198000" />
<workItem from="1534873119036" duration="4624000" />
<workItem from="1536696642254" duration="1497000" />
<workItem from="1536698151028" duration="136000" />
</task>
<task id="LOCAL-00117" summary="Strip out TypedService">
<created>1534732668246</created>
<option name="number" value="00117" />
<option name="presentableId" value="LOCAL-00117" />
<option name="project" value="LOCAL" />
<updated>1534732668246</updated>
<workItem from="1536698151028" duration="788000" />
</task>
<task id="LOCAL-00118" summary="Make reflector a named parameter">
<created>1534732811445</created>
@ -972,7 +1024,14 @@
<option name="project" value="LOCAL" />
<updated>1536698069495</updated>
</task>
<option name="localTasksCounter" value="166" />
<task id="LOCAL-00166" summary="Bump to 2.0.0-alpha.3">
<created>1536698423774</created>
<option name="number" value="00166" />
<option name="presentableId" value="LOCAL-00166" />
<option name="project" value="LOCAL" />
<updated>1536698423774</updated>
</task>
<option name="localTasksCounter" value="167" />
<servers />
</component>
<component name="TestHistory">
@ -1008,7 +1067,7 @@
</history-entry>
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="193674000" />
<option name="totallyTimeSpent" value="194326000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -1028,7 +1087,7 @@
<window_info anchor="bottom" id="Event Log" order="7" sideWeight="0.5035524" side_tool="true" weight="0.34188035" />
<window_info anchor="right" id="Maven Projects" order="3" />
<window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Dart Analysis" order="7" visible="true" weight="0.31004366" />
<window_info anchor="bottom" id="Dart Analysis" order="7" weight="0.31004366" />
<window_info anchor="right" id="Flutter Outline" order="4" />
<window_info id="Capture Tool" order="2" />
<window_info id="Designer" order="2" />
@ -1039,13 +1098,15 @@
<window_info id="UI Designer" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39857143" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.32714286" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.33478895" />
<window_info anchor="right" id="Palette&#9;" order="3" />
<window_info id="Image Layers" order="2" />
<window_info anchor="right" id="Capture Analysis" order="3" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.4964476" weight="0.3973799" />
<window_info anchor="bottom" id="Version Control" order="7" weight="0.32905984" />
<window_info anchor="bottom" id="Terminal" order="7" weight="0.44978166" />
<window_info content_ui="combo" id="Project" order="0" weight="0.28615385" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.28615385" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32905984" />
<window_info anchor="right" id="SciView" order="4" />
<window_info anchor="right" id="Theme Preview" order="3" />
<window_info id="Favorites" order="3" side_tool="true" />
@ -1056,8 +1117,6 @@
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info id="DB Browser" order="2" weight="0.32998413" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.33478895" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32905984" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Data View" order="4" />
<window_info anchor="bottom" id="Message" order="0" />
@ -1071,7 +1130,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value="Remove Angel.inject" />
<MESSAGE value="Remove dep on package:pool" />
<MESSAGE value="waterfall now only accepts RequestHandler" />
<MESSAGE value="Remove req.inject" />
@ -1096,7 +1154,8 @@
<MESSAGE value="Add &lt;Id, Data&gt;" />
<MESSAGE value="Added generic to Routable.use" />
<MESSAGE value="Add generics to hooked service listeners" />
<option name="LAST_COMMIT_MESSAGE" value="Add generics to hooked service listeners" />
<MESSAGE value="Bump to 2.0.0-alpha.3" />
<option name="LAST_COMMIT_MESSAGE" value="Bump to 2.0.0-alpha.3" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@ -1259,13 +1318,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/precontained_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="112">
<caret line="12" column="22" lean-forward="true" selection-start-line="12" selection-start-column="22" selection-end-line="12" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/injection.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="29">
@ -1308,13 +1360,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="128">
<caret line="8" column="35" lean-forward="true" selection-start-line="8" selection-start-column="35" selection-end-line="8" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/di_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
@ -1357,28 +1402,14 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="54">
<caret line="292" column="11" selection-start-line="292" selection-start-column="11" selection-end-line="292" selection-end-column="11" />
<folding>
<element signature="e#39#59#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/typed_service.dart" />
<entry file="file://$PROJECT_DIR$/lib/src/core/request_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="149">
<caret line="29" column="28" selection-start-line="29" selection-start-column="28" selection-end-line="29" selection-end-column="28" />
</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="38">
<caret line="328" column="3" lean-forward="true" selection-start-line="328" selection-start-column="3" selection-end-line="328" selection-end-column="3" />
<folding>
<element signature="e#38#58#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -1386,6 +1417,9 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="70">
<caret line="86" column="17" selection-start-line="86" selection-start-column="17" selection-end-line="86" selection-end-column="17" />
<folding>
<element signature="e#40#60#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
@ -1426,16 +1460,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/services_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="368">
<caret line="23" column="29" selection-start-line="23" selection-start-column="29" selection-end-line="23" selection-end-column="29" />
<folding>
<element signature="e#0#46#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/common.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="151">
@ -1443,10 +1467,13 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/hooked_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="416">
<caret line="125" column="48" lean-forward="true" selection-start-line="125" selection-start-column="48" selection-end-line="125" selection-end-column="48" />
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="144">
<caret line="9" lean-forward="true" selection-start-line="9" selection-end-line="9" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
@ -1457,13 +1484,54 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CHANGELOG.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="80">
<caret line="5" column="66" selection-start-line="5" selection-start-column="66" selection-end-line="5" selection-end-column="66" />
</first_editor>
<second_editor />
<entry file="file://$PROJECT_DIR$/test/hooked_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="416">
<caret line="125" column="48" lean-forward="true" selection-start-line="125" selection-start-column="48" selection-end-line="125" selection-end-column="48" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/services_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16">
<caret line="23" column="29" selection-start-line="23" selection-start-column="29" selection-end-line="23" selection-end-column="29" />
<folding>
<element signature="e#0#46#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="358">
<caret line="191" column="33" lean-forward="true" selection-start-line="191" selection-start-column="33" selection-end-line="191" selection-end-column="33" />
<folding>
<element signature="e#39#59#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/core/request_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="464">
<caret line="29" column="29" selection-start-line="29" selection-start-column="29" selection-end-line="29" selection-end-column="29" />
<folding>
<element signature="e#47#67#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/precontained_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="160">
<caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="159">
<caret line="10" column="12" lean-forward="true" selection-start-line="10" selection-start-column="12" selection-end-line="10" selection-end-column="12" />
</state>
</provider>
</entry>

View file

@ -19,7 +19,7 @@ typedef FutureOr RequestHandler(RequestContext req, ResponseContext res);
/// Sequentially runs a list of [handlers] of middleware, and returns early if any does not
/// return `true`. Works well with [Router].chain.
RequestHandler waterfall(Iterable<RequestHandler> handlers) {
RequestHandler chain(Iterable<RequestHandler> handlers) {
return (req, res) {
Future Function() runPipeline;

View file

@ -19,7 +19,7 @@ main() {
app.get(
'/num/parsed/:num',
waterfall([
chain([
(req, res) {
req.params['n'] = num.parse(req.params['num'].toString());
return true;