Added RequestContext.accepts

This commit is contained in:
thosakwe 2017-07-10 19:08:05 -04:00
parent 9d24d37b56
commit 62dc317239
8 changed files with 325 additions and 150 deletions

View file

@ -2,7 +2,7 @@
<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" />
<option name="testRunnerOptions" value="-j 5" />
<option name="testRunnerOptions" value="-j 4" />
<method />
</configuration>
</component>

View file

@ -1,14 +1,15 @@
<?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 type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/runConfigurations/All_Tests__PRODUCTION_2.xml" />
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="Added RequestContext.accepts">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/CHANGELOG.md" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/test/accepts_test.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/runConfigurations/All_Tests.xml" afterPath="$PROJECT_DIR$/.idea/runConfigurations/All_Tests.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/hooks.dart" afterPath="$PROJECT_DIR$/lib/hooks.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/request_context.dart" afterPath="$PROJECT_DIR$/lib/src/http/request_context.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/service.dart" afterPath="$PROJECT_DIR$/lib/src/http/service.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/hooked_test.dart" afterPath="$PROJECT_DIR$/test/hooked_test.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/test/all.dart" afterPath="$PROJECT_DIR$/test/all.dart" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
@ -32,20 +33,48 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="375">
<file leaf-file-name="pubspec.yaml" pinned="false" current-in-tab="true">
<file leaf-file-name="pubspec.yaml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="21">
<caret line="1" column="16" lean-forward="false" selection-start-line="1" selection-start-column="16" selection-end-line="1" selection-end-column="16" />
<caret line="1" column="14" lean-forward="false" selection-start-line="1" selection-start-column="14" selection-end-line="1" selection-end-column="14" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="84">
<caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding>
<marker date="1497837224385" expanded="true" signature="588:776" ph="{...}" />
</folding>
</first_editor>
<second_editor />
</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="42">
<caret line="2" column="37" lean-forward="false" selection-start-line="2" selection-start-column="37" selection-end-line="2" selection-end-column="37" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="hooks.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/hooks.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="693">
<state relative-caret-position="508">
<caret line="36" column="62" lean-forward="false" selection-start-line="36" selection-start-column="62" selection-end-line="36" selection-end-column="62" />
<folding />
</state>
@ -55,8 +84,40 @@
<file leaf-file-name="request_context.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/request_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="475">
<caret line="208" column="42" lean-forward="false" selection-start-line="208" selection-start-column="42" selection-end-line="208" selection-end-column="42" />
<state relative-caret-position="147">
<caret line="11" column="11" lean-forward="true" selection-start-line="11" selection-start-column="11" selection-end-line="11" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="accepts_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/accepts_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="21" column="20" lean-forward="true" selection-start-line="21" selection-start-column="20" selection-end-line="21" selection-end-column="20" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</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="536">
<caret line="326" column="38" lean-forward="false" selection-start-line="326" selection-start-column="38" selection-end-line="326" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="server_test.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/test/server_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="183">
<caret line="197" column="4" lean-forward="false" selection-start-line="197" selection-start-column="4" selection-end-line="197" selection-end-column="4" />
<folding />
</state>
</provider>
@ -65,27 +126,17 @@
<file leaf-file-name="service.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="588">
<state relative-caret-position="508">
<caret line="42" column="13" lean-forward="true" selection-start-line="42" selection-start-column="13" selection-end-line="42" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
</file>
<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="-1543">
<caret line="58" column="6" lean-forward="false" selection-start-line="58" selection-start-column="6" selection-end-line="58" selection-end-column="6" />
<folding />
</state>
</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">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="403">
<state relative-caret-position="2730">
<caret line="135" column="30" lean-forward="true" selection-start-line="135" selection-start-column="30" selection-end-line="135" selection-end-column="30" />
<folding />
</state>
@ -176,16 +227,18 @@
<option value="$PROJECT_DIR$/lib/src/http/typed_service.dart" />
<option value="$PROJECT_DIR$/test/typed_service_test.dart" />
<option value="$PROJECT_DIR$/test/controller_test.dart" />
<option value="$PROJECT_DIR$/test/all.dart" />
<option value="$PROJECT_DIR$/lib/src/http/hooked_service.dart" />
<option value="$PROJECT_DIR$/tool/travis.sh" />
<option value="$PROJECT_DIR$/test/server_test.dart" />
<option value="$PROJECT_DIR$/lib/src/http/server.dart" />
<option value="$PROJECT_DIR$/lib/hooks.dart" />
<option value="$PROJECT_DIR$/lib/src/http/request_context.dart" />
<option value="$PROJECT_DIR$/lib/src/http/service.dart" />
<option value="$PROJECT_DIR$/test/hooked_test.dart" />
<option value="$PROJECT_DIR$/test/all.dart" />
<option value="$PROJECT_DIR$/test/accepts_test.dart" />
<option value="$PROJECT_DIR$/lib/src/http/request_context.dart" />
<option value="$PROJECT_DIR$/lib/src/http/server.dart" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
</list>
</option>
</component>
@ -219,7 +272,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -316,6 +368,7 @@
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
@ -344,7 +397,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Dart Test.All Tests (PRODUCTION)">
<component name="RunManager" selected="Dart Test.All Tests">
<configuration default="true" type="BashConfigurationType" factoryName="Bash">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="INTERPRETER_PATH" value="C:\Windows\system32\bash.exe" />
@ -425,6 +478,11 @@
<recursive>false</recursive>
<method />
</configuration>
<configuration default="false" name="tests in accepts_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/test/accepts_test.dart" />
<option name="testName" value="accepts_test.dart" />
<method />
</configuration>
<configuration default="false" name="contains provider in before and after in hooked_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/test/hooked_test.dart" />
<option name="scope" value="GROUP_OR_TEST_BY_NAME" />
@ -462,23 +520,24 @@
<option name="testName" value="precontained_test.dart" />
<method />
</configuration>
<list size="16">
<item index="0" class="java.lang.String" itemvalue="Dart Test.contains provider in before and after in hooked_test.dart" />
<item index="1" class="java.lang.String" itemvalue="Dart Test.tests in server_test.dart" />
<item index="2" class="java.lang.String" itemvalue="Dart Test.tests in anonymous_service_test.dart" />
<item index="3" class="java.lang.String" itemvalue="Dart Test.tests in exception_test.dart" />
<item index="4" class="java.lang.String" itemvalue="Dart Test.tests in typed_service_test.dart" />
<item index="5" class="java.lang.String" itemvalue="Dart Test.default view generator in view_generator_test.dart" />
<item index="6" class="java.lang.String" itemvalue="Dart Test.tests in precontained_test.dart" />
<item index="7" class="java.lang.String" itemvalue="Dart Test.Controller Tests" />
<item index="8" class="java.lang.String" itemvalue="Dart Test.DI Tests" />
<item index="9" class="java.lang.String" itemvalue="Dart Test.Hooked Tests" />
<item index="10" class="java.lang.String" itemvalue="Dart Test.Routing Tests" />
<item index="11" class="java.lang.String" itemvalue="Dart Test.All Tests" />
<list size="17">
<item index="0" class="java.lang.String" itemvalue="Dart Test.tests in accepts_test.dart" />
<item index="1" class="java.lang.String" itemvalue="Dart Test.contains provider in before and after in hooked_test.dart" />
<item index="2" class="java.lang.String" itemvalue="Dart Test.tests in server_test.dart" />
<item index="3" class="java.lang.String" itemvalue="Dart Test.tests in anonymous_service_test.dart" />
<item index="4" class="java.lang.String" itemvalue="Dart Test.tests in exception_test.dart" />
<item index="5" class="java.lang.String" itemvalue="Dart Test.tests in typed_service_test.dart" />
<item index="6" class="java.lang.String" itemvalue="Dart Test.default view generator in view_generator_test.dart" />
<item index="7" class="java.lang.String" itemvalue="Dart Test.tests in precontained_test.dart" />
<item index="8" class="java.lang.String" itemvalue="Dart Test.Controller Tests" />
<item index="9" class="java.lang.String" itemvalue="Dart Test.DI Tests" />
<item index="10" class="java.lang.String" itemvalue="Dart Test.Hooked Tests" />
<item index="11" class="java.lang.String" itemvalue="Dart Test.Routing Tests" />
<item index="12" class="java.lang.String" itemvalue="Dart Command Line App.All Tests (for coverage)" />
<item index="13" class="java.lang.String" itemvalue="Dart Command Line App.All Tests (PRODUCTION)" />
<item index="14" class="java.lang.String" itemvalue="Dart Test.tests in server_test.dart (PRODUCTION)" />
<item index="15" class="java.lang.String" itemvalue="Dart Test.All Tests (PRODUCTION)" />
<item index="16" class="java.lang.String" itemvalue="Dart Test.All Tests" />
</list>
</component>
<component name="ShelveChangesManager" show_recycled="false">
@ -516,7 +575,8 @@
<workItem from="1498826328044" duration="5519000" />
<workItem from="1498960523007" duration="89000" />
<workItem from="1499604258765" duration="188000" />
<workItem from="1499618669602" duration="372000" />
<workItem from="1499618669602" duration="520000" />
<workItem from="1499726708949" duration="1371000" />
</task>
<task id="LOCAL-00001" summary="Re-designed exception">
<created>1481237183504</created>
@ -672,27 +732,34 @@
<option name="project" value="LOCAL" />
<updated>1498960583872</updated>
</task>
<option name="localTasksCounter" value="23" />
<task id="LOCAL-00023" summary="1.0.6+2">
<created>1499619046675</created>
<option name="number" value="00023" />
<option name="presentableId" value="LOCAL-00023" />
<option name="project" value="LOCAL" />
<updated>1499619046675</updated>
</task>
<option name="localTasksCounter" value="24" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="All_Tests - 2017.07.09 at 12h 50m 14s.xml">
<history-entry file="All_Tests - 2017.07.10 at 19h 03m 21s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry>
<history-entry file="All_Tests_(PRODUCTION) - 2017.07.09 at 12h 50m 36s.xml">
<configuration name="All Tests (PRODUCTION)" configurationId="DartTestRunConfigurationType" />
<history-entry file="All_Tests - 2017.07.10 at 19h 05m 29s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry>
<history-entry file="contains_provider_in_before_and_after_in_hooked_test_dart - 2017.07.09 at 12h 48m 44s.xml">
<configuration name="contains provider in before and after in hooked_test.dart" configurationId="DartTestRunConfigurationType" />
<history-entry file="All_Tests - 2017.07.10 at 19h 06m 26s.xml">
<configuration name="All Tests" configurationId="DartTestRunConfigurationType" />
</history-entry>
<history-entry file="contains_provider_in_before_and_after_in_hooked_test_dart - 2017.07.09 at 12h 49m 18s.xml">
<configuration name="contains provider in before and after in hooked_test.dart" configurationId="DartTestRunConfigurationType" />
<history-entry file="tests_in_accepts_test_dart - 2017.07.10 at 18h 56m 24s.xml">
<configuration name="tests in accepts_test.dart" configurationId="DartTestRunConfigurationType" />
</history-entry>
<history-entry file="contains_provider_in_before_and_after_in_hooked_test_dart - 2017.07.09 at 12h 49m 28s.xml">
<configuration name="contains provider in before and after in hooked_test.dart" configurationId="DartTestRunConfigurationType" />
<history-entry file="tests_in_accepts_test_dart - 2017.07.10 at 19h 00m 00s.xml">
<configuration name="tests in accepts_test.dart" configurationId="DartTestRunConfigurationType" />
</history-entry>
<history-entry file="tests_in_server_test_dart - 2017.06.30 at 09h 47m 46s.xml">
<configuration name="tests in server_test.dart" configurationId="DartTestRunConfigurationType" />
<history-entry file="tests_in_accepts_test_dart - 2017.07.10 at 19h 01m 20s.xml">
<configuration name="tests in accepts_test.dart" configurationId="DartTestRunConfigurationType" />
</history-entry>
<history-entry file="tests_in_server_test_dart - 2017.06.30 at 09h 48m 07s.xml">
<configuration name="tests in server_test.dart" configurationId="DartTestRunConfigurationType" />
@ -708,7 +775,7 @@
</history-entry>
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="23469000" />
<option name="totallyTimeSpent" value="24988000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -721,13 +788,14 @@
</component>
<component name="ToolWindowManager">
<frame x="-9" y="-9" width="1938" height="1048" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.19989423" sideWeight="0.5" order="0" 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="Messages" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32616082" 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.32802936" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.34314835" sideWeight="0.5" order="2" 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.3295583" sideWeight="0.5" order="1" side_tool="false" 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.3272933" 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.34314835" sideWeight="0.5" order="2" 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="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="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3250283" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@ -736,14 +804,12 @@
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="DB Browser" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32998413" sideWeight="0.5" order="2" 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="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32616082" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Message" 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="0" side_tool="false" content_ui="tabs" />
<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="DB Execution Console" 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="8" 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="Coverage" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="true" 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.3295583" 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="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>
@ -775,35 +841,15 @@
<MESSAGE value="Updated Travis script" />
<MESSAGE value="1.0.6" />
<MESSAGE value="Add stackTrace" />
<option name="LAST_COMMIT_MESSAGE" value="Add stackTrace" />
<MESSAGE value="1.0.6+2" />
<MESSAGE value="Added RequestContext.accepts" />
<option name="LAST_COMMIT_MESSAGE" value="Added RequestContext.accepts" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/lib/src/http/controller.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="14" column="23" lean-forward="false" selection-start-line="14" selection-start-column="23" selection-end-line="14" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http_exception.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="45">
<caret line="3" column="34" lean-forward="true" selection-start-line="3" selection-start-column="34" selection-end-line="3" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http_exception.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="799">
@ -938,16 +984,6 @@
</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">
<first_editor relative-caret-position="84">
<caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/view_generator_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="126">
@ -1032,13 +1068,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/all.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="462">
<caret line="22" column="33" lean-forward="true" selection-start-line="22" selection-start-column="33" selection-end-line="22" selection-end-column="33" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/routable.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="458">
@ -1081,50 +1110,9 @@
</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="164">
<caret line="394" column="18" lean-forward="true" selection-start-line="394" selection-start-column="18" selection-end-line="394" selection-end-column="18" />
<folding>
<element signature="e#38#58#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/server_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="118" column="26" lean-forward="true" selection-start-line="118" selection-start-column="26" selection-end-line="118" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/hooks.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="693">
<caret line="36" column="62" lean-forward="false" selection-start-line="36" selection-start-column="62" selection-end-line="36" selection-end-column="62" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/request_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="475">
<caret line="208" column="42" lean-forward="false" selection-start-line="208" selection-start-column="42" selection-end-line="208" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="588">
<caret line="42" column="13" lean-forward="true" selection-start-line="42" selection-start-column="13" selection-end-line="42" selection-end-column="13" />
<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="-1543">
<state relative-caret-position="1071">
<caret line="58" column="6" lean-forward="false" selection-start-line="58" selection-start-column="6" selection-end-line="58" selection-end-column="6" />
<folding />
</state>
@ -1132,19 +1120,111 @@
</entry>
<entry file="file://$PROJECT_DIR$/test/hooked_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="403">
<state relative-caret-position="2730">
<caret line="135" column="30" lean-forward="true" selection-start-line="135" selection-start-column="30" selection-end-line="135" selection-end-column="30" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-0.12.21/lib/src/frontend/expect_async.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="536">
<caret line="266" column="22" lean-forward="false" selection-start-line="266" selection-start-column="22" selection-end-line="266" selection-end-column="22" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/all.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="19" column="33" lean-forward="false" selection-start-line="19" selection-start-column="33" selection-end-line="19" selection-end-column="33" />
<folding>
<element signature="e#0#38#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/hooks.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="508">
<caret line="36" column="62" lean-forward="false" selection-start-line="36" selection-start-column="62" selection-end-line="36" selection-end-column="62" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/service.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="508">
<caret line="42" column="13" lean-forward="true" selection-start-line="42" selection-start-column="13" selection-end-line="42" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/accepts_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="21" column="20" lean-forward="true" selection-start-line="21" selection-start-column="20" selection-end-line="21" selection-end-column="20" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/request_context.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="147">
<caret line="11" column="11" lean-forward="true" selection-start-line="11" selection-start-column="11" selection-end-line="11" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/test/server_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="183">
<caret line="197" column="4" lean-forward="false" selection-start-line="197" selection-start-column="4" selection-end-line="197" selection-end-column="4" />
<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="536">
<caret line="326" column="38" lean-forward="false" selection-start-line="326" selection-start-column="38" selection-end-line="326" selection-end-column="38" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="21">
<caret line="1" column="16" lean-forward="false" selection-start-line="1" selection-start-column="16" selection-end-line="1" selection-end-column="16" />
<caret line="1" column="14" lean-forward="false" selection-start-line="1" selection-start-column="14" selection-end-line="1" 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">
<first_editor relative-caret-position="84">
<caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding>
<marker date="1497837224385" expanded="true" signature="588:776" ph="{...}" />
</folding>
</first_editor>
<second_editor />
</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="42">
<caret line="2" column="37" lean-forward="false" selection-start-line="2" selection-start-column="37" selection-end-line="2" selection-end-column="37" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</component>
</project>

3
CHANGELOG.md Normal file
View file

@ -0,0 +1,3 @@
# 1.0.7
Added an `accepts` method to `RequestContext`. It's now a lot easier to tell which content types the
user accepts via the `Accept` header.

View file

@ -8,6 +8,8 @@ import 'server.dart' show Angel;
/// A convenience wrapper around an incoming HTTP request.
class RequestContext extends Extensible {
String _acceptHeaderCache;
bool _acceptsAllCache;
BodyParseResult _body;
ContentType _contentType;
HttpRequest _io;
@ -187,6 +189,36 @@ class RequestContext extends Extensible {
injections[type] = value;
}
/// Returns `true` if the client's `Accept` header indicates that the given [contentType] is considered a valid response.
///
/// You cannot provide a `null` [contentType].
/// If the `Accept` header's value is `*/*`, this method will always return `true`.
///
/// [contentType] can be either of the following:
/// * A [ContentType], in which case the `Accept` header will be compared against its `mimeType` property.
/// * Any other Dart value, in which case the `Accept` header will be compared against the result of a `toString()` call.
bool accepts(contentType) {
var contentTypeString = contentType is ContentType
? contentType.mimeType
: contentType?.toString();
if (contentTypeString == null)
throw new ArgumentError(
'RequestContext.accepts expects the `contentType` parameter to NOT be null.');
_acceptHeaderCache ??= headers.value(HttpHeaders.ACCEPT);
if (_acceptHeaderCache == null)
return false;
else if (_acceptHeaderCache.contains('*/*'))
return true;
else
return _acceptHeaderCache.contains(contentTypeString);
}
/// Returns as `true` if the client's `Accept` header indicates that it will accept any response content type.
bool get acceptsAll => _acceptsAllCache ??= accepts('*/*');
/// Retrieves the request body if it has already been parsed, or lazy-parses it before returning the body.
Future<Map> lazyBody() => parse().then((b) => b.body);

View file

@ -324,6 +324,7 @@ class Angel extends AngelBase {
return parent != null ? parent.findProperty(key) : null;
}
/// Handles an [AngelHttpException].
handleAngelHttpException(AngelHttpException e, StackTrace st,
RequestContext req, ResponseContext res, HttpRequest request,
{bool ignoreFinalizers: false}) async {
@ -339,11 +340,10 @@ class Angel extends AngelBase {
}
res.statusCode = e.statusCode;
List<String> accept = request?.headers[HttpHeaders.ACCEPT] ?? ['*/*'];
if (accept.isEmpty ||
accept.contains('*/*') ||
accept.contains(ContentType.JSON.mimeType) ||
accept.contains("application/javascript")) {
if (req.headers.value(HttpHeaders.ACCEPT) == null ||
req.acceptsAll ||
req.accepts(ContentType.JSON) ||
req.accepts('application/javascript')) {
res.serialize(e.toMap(),
contentType: res.headers[HttpHeaders.CONTENT_TYPE] ??
ContentType.JSON.mimeType);

View file

@ -1,5 +1,5 @@
name: angel_framework
version: 1.0.6+2
version: 1.0.7
description: A high-powered HTTP server with DI, routing and more.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_framework

58
test/accepts_test.dart Normal file
View file

@ -0,0 +1,58 @@
import 'dart:async';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:mock_request/mock_request.dart';
import 'package:test/test.dart';
final Uri ENDPOINT = Uri.parse('http://example.com/accept');
main() {
test('no content type', () async {
var req = await acceptContentTypes();
expect(req.acceptsAll, isFalse);
expect(req.accepts(ContentType.JSON), isFalse);
expect(req.accepts('application/json'), isFalse);
expect(req.accepts(ContentType.HTML), isFalse);
expect(req.accepts('text/html'), isFalse);
});
test('wildcard', () async {
var req = await acceptContentTypes(['*/*']);
expect(req.acceptsAll, isTrue);
expect(req.accepts(ContentType.JSON), isTrue);
expect(req.accepts('application/json'), isTrue);
expect(req.accepts(ContentType.HTML), isTrue);
expect(req.accepts('text/html'), isTrue);
});
test('specific type', () async {
var req = await acceptContentTypes(['text/html']);
expect(req.acceptsAll, isFalse);
expect(req.accepts(ContentType.JSON), isFalse);
expect(req.accepts('application/json'), isFalse);
expect(req.accepts(ContentType.HTML), isTrue);
expect(req.accepts('text/html'), isTrue);
});
group('disallow null', () {
RequestContext req;
setUp(() async {
req = await acceptContentTypes();
});
test('throws error', () {
expect(() => req.accepts(null), throwsArgumentError);
});
});
}
Future<RequestContext> acceptContentTypes(
[Iterable<String> contentTypes = const []]) {
var headerString = contentTypes.isEmpty ? null : contentTypes.join(',');
var rq = new MockHttpRequest('GET', ENDPOINT);
rq.headers.set(HttpHeaders.ACCEPT, headerString);
rq.close();
var app = new Angel();
return app.createRequestContext(rq);
}

View file

@ -1,3 +1,4 @@
import 'accepts_test.dart' as accepts;
import 'anonymous_service_test.dart' as anonymous_service;
import 'controller_test.dart' as controller;
import 'di_test.dart' as di;
@ -16,6 +17,7 @@ import 'package:test/test.dart';
/// For running with coverage
main() {
group('accepts', accepts.main);
group('anonymous service', anonymous_service.main);
group('controller', controller.main);
group('di', di.main);