Update example
This commit is contained in:
parent
ed1090fb8e
commit
271456d2ee
3 changed files with 134 additions and 90 deletions
|
@ -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="Update example">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/CHANGELOG.md" afterPath="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/README.md" afterPath="$PROJECT_DIR$/README.md" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/example/main.dart" afterPath="$PROJECT_DIR$/example/main.dart" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.tmp/" />
|
||||
<ignored path="$PROJECT_DIR$/temp/" />
|
||||
|
@ -29,7 +30,7 @@
|
|||
<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="0">
|
||||
<state relative-caret-position="203">
|
||||
<caret line="93" column="12" lean-forward="false" selection-start-line="93" selection-start-column="12" selection-end-line="93" selection-end-column="12" />
|
||||
<folding>
|
||||
<element signature="e#39#59#0" expanded="true" />
|
||||
|
@ -38,14 +39,14 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="README.md" pinned="false" current-in-tab="false">
|
||||
<file leaf-file-name="README.md" pinned="false" current-in-tab="true">
|
||||
<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="150">
|
||||
<caret line="10" column="7" lean-forward="false" selection-start-line="10" selection-start-column="7" selection-end-line="10" selection-end-column="7" />
|
||||
<first_editor relative-caret-position="324">
|
||||
<caret line="44" column="1" lean-forward="false" selection-start-line="44" selection-start-column="1" selection-end-line="44" selection-end-column="1" />
|
||||
<folding>
|
||||
<marker date="1517982736000" expanded="true" signature="588:912" ph="{...}" />
|
||||
<marker date="1523044571000" expanded="true" signature="588:1671" ph="{...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
|
@ -56,8 +57,8 @@
|
|||
<file leaf-file-name="parameter_meta_test.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/parameter_meta_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="256">
|
||||
<caret line="98" column="0" lean-forward="true" selection-start-line="98" selection-start-column="0" selection-end-line="98" selection-end-column="0" />
|
||||
<state relative-caret-position="158">
|
||||
<caret line="40" column="0" lean-forward="true" selection-start-line="40" selection-start-column="0" selection-end-line="40" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -78,7 +79,7 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<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="188">
|
||||
|
@ -90,11 +91,21 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="main.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/example/main.dart">
|
||||
<file leaf-file-name="metadata.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/metadata.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="135">
|
||||
<caret line="9" column="29" lean-forward="false" selection-start-line="9" selection-start-column="29" selection-end-line="9" selection-end-column="29" />
|
||||
<state relative-caret-position="131">
|
||||
<caret line="51" column="8" lean-forward="false" selection-start-line="51" selection-start-column="8" selection-end-line="51" selection-end-column="8" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="injection.dart" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/injection.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="281">
|
||||
<caret line="84" column="0" lean-forward="true" selection-start-line="84" selection-start-column="0" selection-end-line="84" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -122,8 +133,6 @@
|
|||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>close</find>
|
||||
<find>shutdown</find>
|
||||
<find>HttpHeaders</find>
|
||||
<find>ContentType</find>
|
||||
<find>app</find>
|
||||
|
@ -152,6 +161,8 @@
|
|||
<find>unca</find>
|
||||
<find>async</find>
|
||||
<find>hey</find>
|
||||
<find>match</find>
|
||||
<find>getV</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>_isClosed</replace>
|
||||
|
@ -249,15 +260,15 @@
|
|||
<option value="$PROJECT_DIR$/lib/http.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/anonymous_service.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/service.dart" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
<option value="$PROJECT_DIR$/pubspec.yaml" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/map_service.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/core/server.dart" />
|
||||
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/mock_request-1.0.2/lib/src/response.dart" />
|
||||
<option value="$PROJECT_DIR$/lib/src/http/angel_http.dart" />
|
||||
<option value="$PROJECT_DIR$/example/main.dart" />
|
||||
<option value="$PROJECT_DIR$/test/parameter_meta_test.dart" />
|
||||
<option value="$PROJECT_DIR$/CHANGELOG.md" />
|
||||
<option value="$PROJECT_DIR$/example/main.dart" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
@ -689,14 +700,7 @@
|
|||
<workItem from="1517332581856" duration="858000" />
|
||||
<workItem from="1517973177718" duration="9736000" />
|
||||
<workItem from="1522434729364" duration="100000" />
|
||||
<workItem from="1523041434716" duration="2544000" />
|
||||
</task>
|
||||
<task id="LOCAL-00029" summary="1.0.8">
|
||||
<created>1501782730507</created>
|
||||
<option name="number" value="00029" />
|
||||
<option name="presentableId" value="LOCAL-00029" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1501782730507</updated>
|
||||
<workItem from="1523041434716" duration="3129000" />
|
||||
</task>
|
||||
<task id="LOCAL-00030" summary="1.0.9+1">
|
||||
<created>1503934167188</created>
|
||||
|
@ -1034,13 +1038,17 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1523043958692</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="78" />
|
||||
<task id="LOCAL-00078" summary="CHANGELOG">
|
||||
<created>1523043988632</created>
|
||||
<option name="number" value="00078" />
|
||||
<option name="presentableId" value="LOCAL-00078" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1523043988632</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="79" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TestHistory">
|
||||
<history-entry file="injects_session_or_throws_in_parameter_meta_test_dart - 2018.04.06 at 15h 38m 08s.xml">
|
||||
<configuration name="injects session or throws in parameter_meta_test.dart" configurationId="DartTestRunConfigurationType" />
|
||||
</history-entry>
|
||||
<history-entry file="injects_session_or_throws_in_parameter_meta_test_dart - 2018.04.06 at 15h 38m 29s.xml">
|
||||
<configuration name="injects session or throws in parameter_meta_test.dart" configurationId="DartTestRunConfigurationType" />
|
||||
</history-entry>
|
||||
|
@ -1068,9 +1076,12 @@
|
|||
<history-entry file="injects_session_or_throws_in_parameter_meta_test_dart - 2018.04.06 at 15h 45m 48s.xml">
|
||||
<configuration name="injects session or throws in parameter_meta_test.dart" configurationId="DartTestRunConfigurationType" />
|
||||
</history-entry>
|
||||
<history-entry file="injects_session_or_throws_in_parameter_meta_test_dart - 2018.04.06 at 15h 49m 39s.xml">
|
||||
<configuration name="injects session or throws in parameter_meta_test.dart" configurationId="DartTestRunConfigurationType" />
|
||||
</history-entry>
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="130416000" />
|
||||
<option name="totallyTimeSpent" value="131001000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
|
@ -1129,7 +1140,6 @@
|
|||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<MESSAGE value="Remove line that resets `Angel.serializer` on close" />
|
||||
<MESSAGE value="Angel._flattened is now accessible via `optimizedRouter`" />
|
||||
<MESSAGE value="Used function syntax, deprecated `ResponseSerializer` typedef" />
|
||||
<MESSAGE value="Deprecated all serving logic in `Angel`" />
|
||||
|
@ -1154,7 +1164,8 @@
|
|||
<MESSAGE value="MapService dates will be strings" />
|
||||
<MESSAGE value="Bring back zones; mysterious hang" />
|
||||
<MESSAGE value="Fixed tests" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Fixed tests" />
|
||||
<MESSAGE value="CHANGELOG" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="CHANGELOG" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
@ -1298,13 +1309,6 @@
|
|||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core.dart" />
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/metadata.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="251">
|
||||
<caret line="107" column="0" lean-forward="true" selection-start-line="107" selection-start-column="0" selection-end-line="107" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/core.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="150">
|
||||
|
@ -1428,14 +1432,6 @@
|
|||
</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="132">
|
||||
<caret line="26" column="50" lean-forward="false" selection-start-line="26" selection-start-column="50" selection-end-line="26" selection-end-column="50" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/mock_request-1.0.2/lib/src/response.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="318">
|
||||
|
@ -1476,41 +1472,10 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="135">
|
||||
<caret line="9" column="29" lean-forward="false" selection-start-line="9" selection-start-column="29" selection-end-line="9" selection-end-column="29" />
|
||||
<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="150">
|
||||
<caret line="10" column="7" lean-forward="false" selection-start-line="10" selection-start-column="7" selection-end-line="10" selection-end-column="7" />
|
||||
<folding>
|
||||
<marker date="1517982736000" expanded="true" signature="588:912" ph="{...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</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="0">
|
||||
<caret line="93" column="12" lean-forward="false" selection-start-line="93" selection-start-column="12" selection-end-line="93" selection-end-column="12" />
|
||||
<folding>
|
||||
<element signature="e#39#59#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/parameter_meta_test.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="256">
|
||||
<caret line="98" column="0" lean-forward="true" selection-start-line="98" selection-start-column="0" selection-end-line="98" selection-end-column="0" />
|
||||
<state relative-caret-position="158">
|
||||
<caret line="40" column="0" lean-forward="true" selection-start-line="40" selection-start-column="0" selection-end-line="40" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="e#0#20#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1528,6 +1493,40 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/core/metadata.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="131">
|
||||
<caret line="51" column="8" lean-forward="false" selection-start-line="51" selection-start-column="8" selection-end-line="51" selection-end-column="8" />
|
||||
<folding />
|
||||
</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="281">
|
||||
<caret line="84" column="0" lean-forward="true" selection-start-line="84" selection-start-column="0" selection-end-line="84" selection-end-column="0" />
|
||||
<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="203">
|
||||
<caret line="93" column="12" lean-forward="false" selection-start-line="93" selection-start-column="12" selection-end-line="93" selection-end-column="12" />
|
||||
<folding>
|
||||
<element signature="e#39#59#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="170">
|
||||
<caret line="25" column="18" lean-forward="true" selection-start-line="25" selection-start-column="18" selection-end-line="25" selection-end-column="18" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/src/http/angel_http.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="188">
|
||||
|
@ -1538,6 +1537,19 @@
|
|||
</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="324">
|
||||
<caret line="44" column="1" lean-forward="false" selection-start-line="44" selection-start-column="1" selection-end-line="44" selection-end-column="1" />
|
||||
<folding>
|
||||
<marker date="1523044571000" expanded="true" signature="588:1671" ph="{...}" />
|
||||
</folding>
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
|
|
33
README.md
33
README.md
|
@ -14,14 +14,33 @@ import 'package:angel_framework/angel_framework.dart';
|
|||
main() async {
|
||||
var app = new Angel();
|
||||
|
||||
app
|
||||
..get('/hello', (req, res) {
|
||||
res.write('world!');
|
||||
})
|
||||
..post('/date', () => new DateTime.now().toString());
|
||||
// Index route. Returns JSON.
|
||||
app.get('/', () => 'Welcome to Angel!');
|
||||
|
||||
// Accepts a URL like /greet/foo or /greet/bob.
|
||||
app.get('/greet/:name', (String name) => 'Hello, $name!');
|
||||
|
||||
// Pattern matching - only call this handler if the query value of `name` equals 'emoji'.
|
||||
app.get('/greet', (@Query('name', match: 'emoji') String name) => '😇🔥🔥🔥');
|
||||
|
||||
// Handle any other query value of `name`.
|
||||
app.get('/greet', (@Query('name') String name) => 'Hello, $name!');
|
||||
|
||||
// Simple fallback to throw a 404 on unknown paths.
|
||||
app.use((RequestContext req) async {
|
||||
throw new AngelHttpException.notFound(
|
||||
message: 'Unknown path: "${req.uri.path}"',
|
||||
);
|
||||
});
|
||||
|
||||
var http = new AngelHttp(app);
|
||||
var server = await app.startServer('127.0.0.1', 3000);
|
||||
print('Listening at http://${server.address.address}:${server.port}');
|
||||
var server = await http.startServer('127.0.0.1', 3000);
|
||||
var url = 'http://${server.address.address}:${server.port}';
|
||||
print('Listening at $url');
|
||||
print('Visit these pages to see Angel in action:');
|
||||
print('* $url/greet/bob');
|
||||
print('* $url/greet/?name=emoji');
|
||||
print('* $url/greet/?name=jack');
|
||||
print('* $url/nonexistent_page');
|
||||
}
|
||||
```
|
||||
|
|
|
@ -3,12 +3,19 @@ import 'package:angel_framework/angel_framework.dart';
|
|||
main() async {
|
||||
var app = new Angel();
|
||||
|
||||
// Index route. Returns JSON.
|
||||
app.get('/', () => 'Welcome to Angel!');
|
||||
|
||||
// Accepts a URL like /greet/foo or /greet/bob.
|
||||
app.get('/greet/:name', (String name) => 'Hello, $name!');
|
||||
|
||||
app.get('/greet', (@Session('name') String name) => 'Hello, $name!');
|
||||
// Pattern matching - only call this handler if the query value of `name` equals 'emoji'.
|
||||
app.get('/greet', (@Query('name', match: 'emoji') String name) => '😇🔥🔥🔥');
|
||||
|
||||
// Handle any other query value of `name`.
|
||||
app.get('/greet', (@Query('name') String name) => 'Hello, $name!');
|
||||
|
||||
// Simple fallback to throw a 404 on unknown paths.
|
||||
app.use((RequestContext req) async {
|
||||
throw new AngelHttpException.notFound(
|
||||
message: 'Unknown path: "${req.uri.path}"',
|
||||
|
@ -17,5 +24,11 @@ main() async {
|
|||
|
||||
var http = new AngelHttp(app);
|
||||
var server = await http.startServer('127.0.0.1', 3000);
|
||||
print('Listening at http://${server.address.address}:${server.port}');
|
||||
var url = 'http://${server.address.address}:${server.port}';
|
||||
print('Listening at $url');
|
||||
print('Visit these pages to see Angel in action:');
|
||||
print('* $url/greet/bob');
|
||||
print('* $url/greet/?name=emoji');
|
||||
print('* $url/greet/?name=jack');
|
||||
print('* $url/nonexistent_page');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue