Used function syntax, deprecated ResponseSerializer typedef

This commit is contained in:
Tobe O 2018-02-06 22:54:24 -05:00
parent f72b725725
commit f4d9cb3b8e
4 changed files with 150 additions and 146 deletions

View file

@ -1,9 +1,10 @@
<?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="">
<list default="true" id="7b89ff1e-1260-4dcf-9c3d-345de0471ea1" name="Default" comment="Changed signature of serializer">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/src/http/angel_http.dart" afterPath="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/example/json.dart" afterPath="$PROJECT_DIR$/example/json.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" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" />
@ -39,11 +40,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="response_context.dart" pinned="false" current-in-tab="false">
<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="371">
<caret line="310" column="28" lean-forward="false" selection-start-line="310" selection-start-column="28" selection-end-line="310" selection-end-column="28" />
<state relative-caret-position="239">
<caret line="76" column="26" lean-forward="false" selection-start-line="76" selection-start-column="26" selection-end-line="76" selection-end-column="26" />
<folding />
</state>
</provider>
@ -89,57 +90,56 @@
</provider>
</entry>
</file>
<file leaf-file-name="server.dart" pinned="false" current-in-tab="true">
<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="377">
<caret line="63" column="67" lean-forward="false" selection-start-line="63" selection-start-column="67" selection-end-line="63" selection-end-column="67" />
<state relative-caret-position="170">
<caret line="285" column="30" lean-forward="true" selection-start-line="285" selection-start-column="30" selection-end-line="285" selection-end-column="30" />
<folding>
<element signature="e#1951#2006#0" expanded="false" />
<element signature="e#2482#2489#0" expanded="false" />
<element signature="e#2712#2789#0" expanded="false" />
<element signature="e#3047#3142#0" expanded="false" />
<element signature="e#3430#3484#0" expanded="false" />
<element signature="e#3608#3663#0" expanded="false" />
<element signature="e#3789#3830#0" expanded="false" />
<element signature="e#4143#4405#0" expanded="false" />
<element signature="e#5302#5324#0" expanded="false" />
<element signature="e#5452#5767#0" expanded="false" />
<element signature="e#5878#6225#0" expanded="false" />
<element signature="e#6315#6682#0" expanded="false" />
<element signature="e#6775#7013#0" expanded="false" />
<element signature="e#7017#7084#0" expanded="false" />
<element signature="e#7188#7866#0" expanded="false" />
<element signature="e#8028#8668#0" expanded="false" />
<element signature="e#8780#8815#0" expanded="false" />
<element signature="e#8988#9029#0" expanded="false" />
<element signature="e#9144#9183#0" expanded="false" />
<element signature="e#9268#9985#0" expanded="false" />
<element signature="e#10154#10655#0" expanded="false" />
<element signature="e#10358#10424#0" expanded="false" />
<element signature="e#10792#10845#0" expanded="false" />
<element signature="e#11207#11350#0" expanded="false" />
<element signature="e#11449#11582#0" expanded="false" />
<element signature="e#11829#11955#0" expanded="false" />
<element signature="e#12069#12115#0" expanded="false" />
<element signature="e#12119#12181#0" expanded="false" />
<element signature="e#12497#13129#0" expanded="false" />
<element signature="e#12590#12714#0" expanded="false" />
<element signature="e#12748#12993#0" expanded="false" />
<element signature="e#13133#13191#0" expanded="false" />
<element signature="e#13425#13600#0" expanded="false" />
<element signature="e#13756#13945#0" expanded="false" />
<element signature="e#14144#14199#0" expanded="false" />
<element signature="e#14332#14399#0" expanded="false" />
<element signature="e#14501#14540#0" expanded="false" />
<element signature="e#14544#14605#0" expanded="false" />
<element signature="e#15031#16106#0" expanded="false" />
<element signature="e#16158#16236#0" expanded="false" />
<element signature="e#16304#16566#0" expanded="false" />
<element signature="e#16696#16761#0" expanded="false" />
<element signature="e#16824#17018#0" expanded="false" />
<element signature="e#17022#17050#0" expanded="false" />
<element signature="e#17342#17761#0" expanded="false" />
<element signature="e#38#58#0" expanded="true" />
<element signature="e#1957#2012#0" expanded="false" />
<element signature="e#2488#2495#0" expanded="false" />
<element signature="e#2718#2795#0" expanded="false" />
<element signature="e#3053#3148#0" expanded="false" />
<element signature="e#3436#3490#0" expanded="false" />
<element signature="e#3614#3669#0" expanded="false" />
<element signature="e#3795#3836#0" expanded="false" />
<element signature="e#4149#4411#0" expanded="false" />
<element signature="e#5308#5330#0" expanded="false" />
<element signature="e#5884#6231#0" expanded="false" />
<element signature="e#6321#6688#0" expanded="false" />
<element signature="e#6781#7019#0" expanded="false" />
<element signature="e#7023#7090#0" expanded="false" />
<element signature="e#7194#7872#0" expanded="false" />
<element signature="e#8034#8674#0" expanded="false" />
<element signature="e#8786#8821#0" expanded="false" />
<element signature="e#8994#9035#0" expanded="false" />
<element signature="e#9265#9982#0" expanded="false" />
<element signature="e#10151#10652#0" expanded="false" />
<element signature="e#10355#10421#0" expanded="false" />
<element signature="e#10789#10842#0" expanded="false" />
<element signature="e#11204#11347#0" expanded="false" />
<element signature="e#11446#11579#0" expanded="false" />
<element signature="e#11826#11952#0" expanded="false" />
<element signature="e#12066#12112#0" expanded="false" />
<element signature="e#12116#12178#0" expanded="false" />
<element signature="e#12494#13126#0" expanded="false" />
<element signature="e#12587#12711#0" expanded="false" />
<element signature="e#12745#12990#0" expanded="false" />
<element signature="e#13130#13188#0" expanded="false" />
<element signature="e#13422#13597#0" expanded="false" />
<element signature="e#13753#13942#0" expanded="false" />
<element signature="e#14141#14196#0" expanded="false" />
<element signature="e#14329#14396#0" expanded="false" />
<element signature="e#14498#14537#0" expanded="false" />
<element signature="e#14541#14602#0" expanded="false" />
<element signature="e#15028#16103#0" expanded="false" />
<element signature="e#16155#16233#0" expanded="false" />
<element signature="e#16301#16563#0" expanded="false" />
<element signature="e#16693#16758#0" expanded="false" />
<element signature="e#16821#17015#0" expanded="false" />
<element signature="e#17019#17047#0" expanded="false" />
<element signature="e#17339#17758#0" expanded="false" />
</folding>
</state>
</provider>
@ -182,11 +182,11 @@
</split-first>
<split-second>
<leaf>
<file leaf-file-name="angel_http.dart" pinned="false" current-in-tab="true">
<file leaf-file-name="angel_http.dart" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="152">
<caret line="33" column="39" lean-forward="false" selection-start-line="33" selection-start-column="39" selection-end-line="33" selection-end-column="39" />
<state relative-caret-position="430">
<caret line="38" column="52" lean-forward="true" selection-start-line="38" selection-start-column="52" selection-end-line="38" selection-end-column="52" />
<folding>
<element signature="e#0#20#0" expanded="true" />
<element signature="e#1191#1196#0" expanded="false" />
@ -196,11 +196,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="json.dart" pinned="false" current-in-tab="false">
<file leaf-file-name="json.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/example/json.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="233">
<caret line="42" column="6" lean-forward="false" selection-start-line="42" selection-start-column="6" selection-end-line="42" selection-end-column="6" />
<state relative-caret-position="281">
<caret line="42" column="12" lean-forward="false" selection-start-line="42" selection-start-column="12" selection-end-line="42" selection-end-column="12" />
<folding />
</state>
</provider>
@ -219,8 +219,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>sendResponse</find>
<find>addStream</find>
<find>Lo</find>
<find>useStr</find>
<find>_injections?</find>
@ -247,8 +245,10 @@
<find>((cre)|(upd))atedAt</find>
<find>'((cre)|(upd))atedAt'</find>
<find>handleReque</find>
<find>injectSeri</find>
<find>optimize</find>
<find>serializer`</find>
<find>serializer</find>
<find>injectSeri</find>
</findStrings>
<replaceStrings>
<replace>_isClosed</replace>
@ -314,7 +314,6 @@
<option value="$PROJECT_DIR$/test/services_test.dart" />
<option value="$PROJECT_DIR$/test/streaming_test.dart" />
<option value="$PROJECT_DIR$/test/encoders_buffer_test.dart" />
<option value="$PROJECT_DIR$/example/json.dart" />
<option value="$PROJECT_DIR$/lib/src/http/pattern_matcher.dart" />
<option value="$PROJECT_DIR$/lib/src/http/controller.dart" />
<option value="$PROJECT_DIR$/lib/src/http/metadata.dart" />
@ -341,12 +340,13 @@
<option value="$PROJECT_DIR$/test/extension_test.dart" />
<option value="$PROJECT_DIR$/test/all.dart" />
<option value="$PROJECT_DIR$/lib/src/http/service.dart" />
<option value="$PROJECT_DIR$/lib/src/http/response_context.dart" />
<option value="$PROJECT_DIR$/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/http/map_service.dart" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/lib/src/http/server.dart" />
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
<option value="$PROJECT_DIR$/example/json.dart" />
<option value="$PROJECT_DIR$/lib/src/http/server.dart" />
<option value="$PROJECT_DIR$/lib/src/http/response_context.dart" />
</list>
</option>
</component>
@ -754,14 +754,7 @@
<workItem from="1513103483207" duration="18000" />
<workItem from="1513103506825" duration="139000" />
<workItem from="1517332581856" duration="858000" />
<workItem from="1517973177718" duration="2311000" />
</task>
<task id="LOCAL-00005" summary="findExpose">
<created>1483150316137</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1483150316138</updated>
<workItem from="1517973177718" duration="2463000" />
</task>
<task id="LOCAL-00006" summary="I love stack overflows!!!">
<created>1483150975010</created>
@ -1099,7 +1092,14 @@
<option name="project" value="LOCAL" />
<updated>1517975399809</updated>
</task>
<option name="localTasksCounter" value="54" />
<task id="LOCAL-00054" summary="Angel._flattened is now accessible via `optimizedRouter`">
<created>1517975513004</created>
<option name="number" value="00054" />
<option name="presentableId" value="LOCAL-00054" />
<option name="project" value="LOCAL" />
<updated>1517975513004</updated>
</task>
<option name="localTasksCounter" value="55" />
<servers />
</component>
<component name="TestHistory">
@ -1135,7 +1135,7 @@
</history-entry>
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="120347000" />
<option name="totallyTimeSpent" value="120499000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
@ -1194,7 +1194,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value="1.0.8" />
<MESSAGE value="1.0.9+1" />
<MESSAGE value="1.1.0-alpha start" />
<MESSAGE value="1.1.0-alpha" />
@ -1219,10 +1218,13 @@
<MESSAGE value="Basic server methods transferred to AngelHttp" />
<MESSAGE value="Made `Angel.serializer` public" />
<MESSAGE value="Remove line that resets `Angel.serializer` on close" />
<option name="LAST_COMMIT_MESSAGE" value="Remove line that resets `Angel.serializer` on close" />
<MESSAGE value="Angel._flattened is now accessible via `optimizedRouter`" />
<option name="LAST_COMMIT_MESSAGE" value="Angel._flattened is now accessible via `optimizedRouter`" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<breakpoint-manager>
<option name="time" value="1" />
</breakpoint-manager>
<watches-manager />
</component>
<component name="editorHistoryManager">
@ -1533,14 +1535,6 @@
</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="371">
<caret line="310" column="28" lean-forward="false" selection-start-line="310" selection-start-column="28" selection-end-line="310" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
@ -1583,80 +1577,87 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="377">
<caret line="63" column="67" lean-forward="false" selection-start-line="63" selection-start-column="67" selection-end-line="63" selection-end-column="67" />
<state relative-caret-position="430">
<caret line="38" column="52" lean-forward="true" selection-start-line="38" selection-start-column="52" selection-end-line="38" selection-end-column="52" />
<folding>
<element signature="e#1951#2006#0" expanded="false" />
<element signature="e#2482#2489#0" expanded="false" />
<element signature="e#2712#2789#0" expanded="false" />
<element signature="e#3047#3142#0" expanded="false" />
<element signature="e#3430#3484#0" expanded="false" />
<element signature="e#3608#3663#0" expanded="false" />
<element signature="e#3789#3830#0" expanded="false" />
<element signature="e#4143#4405#0" expanded="false" />
<element signature="e#5302#5324#0" expanded="false" />
<element signature="e#5452#5767#0" expanded="false" />
<element signature="e#5878#6225#0" expanded="false" />
<element signature="e#6315#6682#0" expanded="false" />
<element signature="e#6775#7013#0" expanded="false" />
<element signature="e#7017#7084#0" expanded="false" />
<element signature="e#7188#7866#0" expanded="false" />
<element signature="e#8028#8668#0" expanded="false" />
<element signature="e#8780#8815#0" expanded="false" />
<element signature="e#8988#9029#0" expanded="false" />
<element signature="e#9144#9183#0" expanded="false" />
<element signature="e#9268#9985#0" expanded="false" />
<element signature="e#10154#10655#0" expanded="false" />
<element signature="e#10358#10424#0" expanded="false" />
<element signature="e#10792#10845#0" expanded="false" />
<element signature="e#11207#11350#0" expanded="false" />
<element signature="e#11449#11582#0" expanded="false" />
<element signature="e#11829#11955#0" expanded="false" />
<element signature="e#12069#12115#0" expanded="false" />
<element signature="e#12119#12181#0" expanded="false" />
<element signature="e#12497#13129#0" expanded="false" />
<element signature="e#12590#12714#0" expanded="false" />
<element signature="e#12748#12993#0" expanded="false" />
<element signature="e#13133#13191#0" expanded="false" />
<element signature="e#13425#13600#0" expanded="false" />
<element signature="e#13756#13945#0" expanded="false" />
<element signature="e#14144#14199#0" expanded="false" />
<element signature="e#14332#14399#0" expanded="false" />
<element signature="e#14501#14540#0" expanded="false" />
<element signature="e#14544#14605#0" expanded="false" />
<element signature="e#15031#16106#0" expanded="false" />
<element signature="e#16158#16236#0" expanded="false" />
<element signature="e#16304#16566#0" expanded="false" />
<element signature="e#16696#16761#0" expanded="false" />
<element signature="e#16824#17018#0" expanded="false" />
<element signature="e#17022#17050#0" expanded="false" />
<element signature="e#17342#17761#0" expanded="false" />
<element signature="e#0#20#0" expanded="true" />
<element signature="e#1191#1196#0" expanded="false" />
<element signature="e#1499#1524#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/json.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="233">
<caret line="42" column="6" lean-forward="false" selection-start-line="42" selection-start-column="6" selection-end-line="42" selection-end-column="6" />
<state relative-caret-position="281">
<caret line="42" column="12" lean-forward="false" selection-start-line="42" selection-start-column="12" selection-end-line="42" selection-end-column="12" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
<entry file="file://$PROJECT_DIR$/lib/src/http/server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="152">
<caret line="33" column="39" lean-forward="false" selection-start-line="33" selection-start-column="39" selection-end-line="33" selection-end-column="39" />
<state relative-caret-position="170">
<caret line="285" column="30" lean-forward="true" selection-start-line="285" selection-start-column="30" selection-end-line="285" selection-end-column="30" />
<folding>
<element signature="e#0#20#0" expanded="true" />
<element signature="e#1191#1196#0" expanded="false" />
<element signature="e#1499#1524#0" expanded="false" />
<element signature="e#38#58#0" expanded="true" />
<element signature="e#1957#2012#0" expanded="false" />
<element signature="e#2488#2495#0" expanded="false" />
<element signature="e#2718#2795#0" expanded="false" />
<element signature="e#3053#3148#0" expanded="false" />
<element signature="e#3436#3490#0" expanded="false" />
<element signature="e#3614#3669#0" expanded="false" />
<element signature="e#3795#3836#0" expanded="false" />
<element signature="e#4149#4411#0" expanded="false" />
<element signature="e#5308#5330#0" expanded="false" />
<element signature="e#5884#6231#0" expanded="false" />
<element signature="e#6321#6688#0" expanded="false" />
<element signature="e#6781#7019#0" expanded="false" />
<element signature="e#7023#7090#0" expanded="false" />
<element signature="e#7194#7872#0" expanded="false" />
<element signature="e#8034#8674#0" expanded="false" />
<element signature="e#8786#8821#0" expanded="false" />
<element signature="e#8994#9035#0" expanded="false" />
<element signature="e#9265#9982#0" expanded="false" />
<element signature="e#10151#10652#0" expanded="false" />
<element signature="e#10355#10421#0" expanded="false" />
<element signature="e#10789#10842#0" expanded="false" />
<element signature="e#11204#11347#0" expanded="false" />
<element signature="e#11446#11579#0" expanded="false" />
<element signature="e#11826#11952#0" expanded="false" />
<element signature="e#12066#12112#0" expanded="false" />
<element signature="e#12116#12178#0" expanded="false" />
<element signature="e#12494#13126#0" expanded="false" />
<element signature="e#12587#12711#0" expanded="false" />
<element signature="e#12745#12990#0" expanded="false" />
<element signature="e#13130#13188#0" expanded="false" />
<element signature="e#13422#13597#0" expanded="false" />
<element signature="e#13753#13942#0" expanded="false" />
<element signature="e#14141#14196#0" expanded="false" />
<element signature="e#14329#14396#0" expanded="false" />
<element signature="e#14498#14537#0" expanded="false" />
<element signature="e#14541#14602#0" expanded="false" />
<element signature="e#15028#16103#0" expanded="false" />
<element signature="e#16155#16233#0" expanded="false" />
<element signature="e#16301#16563#0" expanded="false" />
<element signature="e#16693#16758#0" expanded="false" />
<element signature="e#16821#17015#0" expanded="false" />
<element signature="e#17019#17047#0" expanded="false" />
<element signature="e#17339#17758#0" expanded="false" />
</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="239">
<caret line="76" column="26" lean-forward="false" selection-start-line="76" selection-start-column="26" selection-end-line="76" selection-end-column="26" />
<folding />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>

View file

@ -40,7 +40,7 @@ serverMain(_) async {
// Performance tuning
app
..lazyParseBodies = true
..injectSerializer(JSON.encode);
..serializer = JSON.encode;
app.errorHandler = (e, req, res) {
print(e.message ?? e.error ?? e);

View file

@ -17,6 +17,9 @@ final RegExp _contentType =
final RegExp _straySlashes = new RegExp(r'(^/+)|(/+$)');
/// Serializes response data into a String.
///
/// Prefer the String Function(dynamic) syntax.
@deprecated
typedef String ResponseSerializer(data);
/// A convenience wrapper around an outgoing HTTP request.
@ -71,7 +74,7 @@ class ResponseContext implements StreamSink<List<int>>, StringSink {
/// ```dart
/// app.injectSerializer(JSON.encode);
/// ```
ResponseSerializer serializer = god.serialize;
String Function(dynamic) serializer = god.serialize;
/// This response's status code.
int get statusCode => _statusCode;

View file

@ -54,7 +54,7 @@ class Angel extends AngelBase {
final Map<dynamic, InjectionRequest> _preContained = {};
/// A middleware to inject a serialize on every request.
ResponseSerializer serializer;
String Function(dynamic) serializer;
/// A [Map] of dependency data obtained via reflection.
///
@ -283,7 +283,7 @@ class Angel extends AngelBase {
/// Prefer directly setting [serializer].
@deprecated
void injectSerializer(ResponseSerializer serializer) {
void injectSerializer(String serializer(x)) {
this.serializer = serializer;
}