Entering beta. JSON God dep removed, ironically.
This commit is contained in:
parent
6146e410ec
commit
5b7025815a
6 changed files with 431 additions and 58 deletions
323
.idea/libraries/Dart_Packages.xml
Normal file
323
.idea/libraries/Dart_Packages.xml
Normal file
|
@ -0,0 +1,323 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Dart Packages" type="DartPackagesLibraryType">
|
||||
<properties>
|
||||
<option name="packageNameToDirsMap">
|
||||
<entry key="analyzer">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.27.2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="args">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-0.13.4/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="async">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-1.10.0/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="barback">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/barback-0.15.2+7/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="boolean_selector">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-1.0.1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="charcode">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.1.0/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="collection">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.5.1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="convert">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-1.0.1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="crypto">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-1.0.0/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="csslib">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/csslib-0.12.2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="glob">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-1.1.2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="html">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/html-0.12.2+1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="http">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.11.3+3/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="http_multi_server">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-2.0.1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="http_parser">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-2.2.1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="json_god">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/json_god-1.0.0/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="logging">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="matcher">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.0+2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="mime">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-0.9.3/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="package_config">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-0.1.3/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="path">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.3.9/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="plugin">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin-0.1.0/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="pool">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.2.3/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="pub_semver">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-1.2.4/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="shelf">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-0.6.5/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="shelf_static">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-0.2.3+3/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="shelf_web_socket">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.0/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="source_map_stack_trace">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-1.0.4/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="source_maps">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.1+1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="source_span">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.2.2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="stack_trace">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.6.5/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="stream_channel">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-1.3.1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="string_scanner">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-0.1.4+1/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="test">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-0.12.13/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="typed_data">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.1.2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="utf">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/utf-0.9.0+3/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="watcher">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-0.9.7/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="web_socket_channel">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-1.0.2/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="yaml">
|
||||
<value>
|
||||
<list>
|
||||
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-2.1.8/lib" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
</option>
|
||||
</properties>
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.27.2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-0.13.4/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-1.10.0/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/barback-0.15.2+7/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-1.0.1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.1.0/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.5.1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-1.0.1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-1.0.0/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/csslib-0.12.2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-1.1.2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/html-0.12.2+1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.11.3+3/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-2.0.1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-2.2.1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/json_god-1.0.0/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.0+2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-0.9.3/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-0.1.3/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.3.9/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin-0.1.0/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.2.3/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-1.2.4/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-0.6.5/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-0.2.3+3/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.0/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-1.0.4/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.1+1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.2.2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.6.5/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-1.3.1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-0.1.4+1/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-0.12.13/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.1.2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/utf-0.9.0+3/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-0.9.7/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-1.0.2/lib" />
|
||||
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-2.1.8/lib" />
|
||||
</CLASSES>
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,9 +1,9 @@
|
|||
# Body Parser
|
||||
![version 1.0.0-dev](https://img.shields.io/badge/version-1.0.0--dev-red.svg)
|
||||
![version 1.0.0-beta](https://img.shields.io/badge/version-1.0.0--beta-blue.svg)
|
||||
|
||||
**NOT YET PRODUCTION READY**
|
||||
|
||||
Parse request bodies and query strings in Dart.
|
||||
Parse request bodies and query strings in Dart. No external dependencies required.
|
||||
|
||||
### Contents
|
||||
|
||||
|
|
|
@ -572,8 +572,8 @@ jQuery.cookie = function(name, value, options) {
|
|||
<body>
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<div class="time">656 ms</div>
|
||||
<h1>Run All Tests: <strong><span class="total">6 total, </span><span class="ignored">2 ignored, </span><span class="passed">4 passed</span></strong>
|
||||
<div class="time">1.05 s</div>
|
||||
<h1>Run All Tests: <strong><span class="total">6 total, </span><span class="passed">6 passed</span></strong>
|
||||
</h1>
|
||||
<div id="treecontrol">
|
||||
<ul>
|
||||
|
@ -589,73 +589,94 @@ jQuery.cookie = function(name, value, options) {
|
|||
</div>
|
||||
<div id="content">
|
||||
<ul id="tree">
|
||||
<li xmlns="" class="level top ignored open">
|
||||
<li xmlns="" class="level top open">
|
||||
<span><em class="time">
|
||||
<div class="time">656 ms</div>
|
||||
<div class="time">1.05 s</div>
|
||||
</em>all_tests.dart</span>
|
||||
<ul>
|
||||
<li class="level suite open">
|
||||
<span><em class="time">
|
||||
<div class="time">1.05 s</div>
|
||||
</em>Test server support</span>
|
||||
<ul>
|
||||
<li class="level suite ignored open">
|
||||
<li class="level suite open">
|
||||
<span><em class="time">
|
||||
<div class="time">477 ms</div>
|
||||
<div class="time">779 ms</div>
|
||||
</em>query string</span>
|
||||
<ul>
|
||||
<li class="level test">
|
||||
<span><em class="time">
|
||||
<div class="time">477 ms</div>
|
||||
<div class="time">680 ms</div>
|
||||
</em><em class="status">passed</em>GET Simple</span>
|
||||
<ul>
|
||||
<li class="text">
|
||||
<span class="stdout">Test server listening on http://localhost:62263<br/>GET http://localhost:62263/?hello=world<br/>Response: {"body":{},"query":{"hello":"world"}}<br/></span>
|
||||
<span class="stdout">Test server listening on http://localhost:55407<br/>GET http://localhost:55407/?hello=world<br/>Response: {"body":{},"query":{"hello":"world"}}<br/></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="level test ignored open">
|
||||
<span><em class="time"></em><em class="status">ignored</em>GET Complex</span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="level suite ignored open">
|
||||
<span><em class="time">
|
||||
<div class="time">53 ms</div>
|
||||
</em>urlencoded</span>
|
||||
<ul>
|
||||
<li class="level test">
|
||||
<span><em class="time">
|
||||
<div class="time">53 ms</div>
|
||||
</em><em class="status">passed</em>POST Simple</span>
|
||||
<div class="time">99 ms</div>
|
||||
</em><em class="status">passed</em>GET Complex</span>
|
||||
<ul>
|
||||
<li class="text">
|
||||
<span class="stdout">Test server listening on http://localhost:62265<br/>Body: hello=world<br/>Response: {"body":{"hello":"world"},"query":{}}<br/></span>
|
||||
<span class="stdout">Test server listening on http://localhost:55409<br/>Body: hello=world&nums%5B%5D=1&nums%5B%5D=2.0&nums%5B%5D=2&map.foo.bar=baz<br/>Response: {"body":{},"query":{"hello":"world","nums":[1,2.0,2],"map":{"foo":{"bar":"baz"}}}}<br/></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="level test ignored open">
|
||||
<span><em class="time"></em><em class="status">ignored</em>Post Complex</span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="level suite open">
|
||||
<span><em class="time">
|
||||
<div class="time">126 ms</div>
|
||||
</em>JSON</span>
|
||||
<div class="time">195 ms</div>
|
||||
</em>urlencoded</span>
|
||||
<ul>
|
||||
<li class="level test">
|
||||
<span><em class="time">
|
||||
<div class="time">85 ms</div>
|
||||
</em><em class="status">passed</em>Post Simple</span>
|
||||
<div class="time">162 ms</div>
|
||||
</em><em class="status">passed</em>POST Simple</span>
|
||||
<ul>
|
||||
<li class="text">
|
||||
<span class="stdout">Test server listening on http://localhost:62267<br/>Body: {"hello":"world"}<br/>Response: {"body":{"hello":"world"},"query":{}}<br/></span>
|
||||
<span class="stdout">Test server listening on http://localhost:55411<br/>Body: hello=world<br/>Response: {"body":{"hello":"world"},"query":{}}<br/></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="level test">
|
||||
<span><em class="time">
|
||||
<div class="time">41 ms</div>
|
||||
<div class="time">33 ms</div>
|
||||
</em><em class="status">passed</em>Post Complex</span>
|
||||
<ul>
|
||||
<li class="text">
|
||||
<span class="stdout">Test server listening on http://localhost:62269<br/>Body: {"hello":"world","nums":[1,2.0,2],"map":{"foo":{"bar":"baz"}}}<br/>Response: {"body":{"hello":"world","nums":[1,2.0,2],"map":{"foo":{"bar":"baz"}}},"query":{}}<br/></span>
|
||||
<span class="stdout">Test server listening on http://localhost:55413<br/></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="level suite open">
|
||||
<span><em class="time">
|
||||
<div class="time">74 ms</div>
|
||||
</em>JSON</span>
|
||||
<ul>
|
||||
<li class="level test">
|
||||
<span><em class="time">
|
||||
<div class="time">31 ms</div>
|
||||
</em><em class="status">passed</em>Post Simple</span>
|
||||
<ul>
|
||||
<li class="text">
|
||||
<span class="stdout">Test server listening on http://localhost:55415<br/>Body: {"hello":"world"}<br/>Response: {"body":{"hello":"world"},"query":{}}<br/></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="level test">
|
||||
<span><em class="time">
|
||||
<div class="time">43 ms</div>
|
||||
</em><em class="status">passed</em>Post Complex</span>
|
||||
<ul>
|
||||
<li class="text">
|
||||
<span class="stdout">Test server listening on http://localhost:55417<br/>Body: {"hello":"world","nums":[1,2.0,2],"map":{"foo":{"bar":"baz"}}}<br/>Response: {"body":{"hello":"world","nums":[1,2.0,2],"map":{"foo":{"bar":"baz"}}},"query":{}}<br/></span>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -667,7 +688,7 @@ jQuery.cookie = function(name, value, options) {
|
|||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<p>Generated by WebStorm on 3/3/16 11:11 PM</p>
|
||||
<p>Generated by WebStorm on 4/16/16 11:06 PM</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,7 +4,6 @@ library body_parser;
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:json_god/json_god.dart';
|
||||
|
||||
/// A representation of data from an incoming request.
|
||||
class BodyParseResult {
|
||||
|
@ -47,22 +46,51 @@ Future<BodyParseResult> parseBody(HttpRequest request) async {
|
|||
///
|
||||
/// Whichever map you provide will be automatically populated from the urlencoded body string you provide.
|
||||
buildMapFromUri(Map map, String body) {
|
||||
God god = new God();
|
||||
RegExp parseArray = new RegExp(r'^(.+)\[\]$');
|
||||
|
||||
for (String keyValuePair in body.split('&')) {
|
||||
if (keyValuePair.contains('=')) {
|
||||
List<String> split = keyValuePair.split('=');
|
||||
String key = Uri.decodeQueryComponent(split[0]);
|
||||
String value = Uri.decodeQueryComponent(split[1]);
|
||||
num numValue = num.parse(value, (_) => double.NAN);
|
||||
if (!numValue.isNaN)
|
||||
map[key] = numValue;
|
||||
else if (value.startsWith('[') && value.endsWith(']'))
|
||||
map[key] = god.deserialize(value);
|
||||
else if (value.startsWith('{') && value.endsWith('}'))
|
||||
map[key] = god.deserialize(value);
|
||||
else if (value.trim().toLowerCase() == 'null')
|
||||
map[key] = null;
|
||||
else map[key] = value;
|
||||
|
||||
if (parseArray.hasMatch(key)) {
|
||||
Match queryMatch = parseArray.firstMatch(key);
|
||||
key = queryMatch.group(1);
|
||||
if (!(map[key] is List)) {
|
||||
map[key] = [];
|
||||
}
|
||||
|
||||
map[key].add(getValue(value));
|
||||
} else if(key.contains('.')) {
|
||||
// i.e. map.foo.bar => [map, foo, bar]
|
||||
List<String> keys = key.split('.');
|
||||
|
||||
Map targetMap = map[keys[0]] ?? {};
|
||||
map[keys[0]] = targetMap;
|
||||
for (int i = 1; i < keys.length; i++) {
|
||||
if (i < keys.length - 1) {
|
||||
targetMap[keys[i]] = targetMap[keys[i]] ?? {};
|
||||
targetMap = targetMap[keys[i]];
|
||||
} else {
|
||||
targetMap[keys[i]] = getValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else map[key] = getValue(value);
|
||||
} else map[Uri.decodeQueryComponent(keyValuePair)] = true;
|
||||
}
|
||||
}
|
||||
|
||||
getValue(String value) {
|
||||
num numValue = num.parse(value, (_) => double.NAN);
|
||||
if (!numValue.isNaN)
|
||||
return numValue;
|
||||
else if (value.startsWith('[') && value.endsWith(']'))
|
||||
return JSON.decode(value);
|
||||
else if (value.startsWith('{') && value.endsWith('}'))
|
||||
return JSON.decode(value);
|
||||
else if (value.trim().toLowerCase() == 'null')
|
||||
return null;
|
||||
else return value;
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
name: body_parser
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
version: 1.0.0-dev
|
||||
version: 1.0.0-beta
|
||||
description: Parse request bodies and query strings in Dart.
|
||||
dependencies:
|
||||
json_god: any
|
||||
dev_dependencies:
|
||||
http: any
|
||||
json_god: any
|
||||
test: any
|
|
@ -42,15 +42,17 @@ main() {
|
|||
});
|
||||
|
||||
test('GET Complex', () async {
|
||||
var postData = 'hello=world&nums[]=1&nums[]=2.0&nums[]=${3 -
|
||||
var postData = 'hello=world&nums%5B%5D=1&nums%5B%5D=2.0&nums%5B%5D=${3 -
|
||||
1}&map.foo.bar=baz';
|
||||
print('Body: $postData');
|
||||
var response = await client.get('$url/?$postData');
|
||||
var body = god.deserialize(response.body)['body'];
|
||||
expect(body['hello'], equals('world'));
|
||||
expect(body['nums'][2], equals(2));
|
||||
expect(body['map'] is Map, equals(true));
|
||||
expect(body['map']['foo'], equals({'bar': 'baz'}));
|
||||
}, skip: 'Array support via query string is pending.');
|
||||
print('Response: ${response.body}');
|
||||
var query = god.deserialize(response.body)['query'];
|
||||
expect(query['hello'], equals('world'));
|
||||
expect(query['nums'][2], equals(2));
|
||||
expect(query['map'] is Map, equals(true));
|
||||
expect(query['map']['foo'], equals({'bar': 'baz'}));
|
||||
});
|
||||
});
|
||||
|
||||
group('urlencoded', () {
|
||||
|
@ -66,7 +68,7 @@ main() {
|
|||
});
|
||||
|
||||
test('Post Complex', () async {
|
||||
var postData = 'hello=world&nums[]=1&nums[]=2.0&nums[]=${3 -
|
||||
var postData = 'hello=world&nums%5B%5D=1&nums%5B%5D=2.0&nums%5B%5D=${3 -
|
||||
1}&map.foo.bar=baz';
|
||||
var response = await client.post(url, headers: headers, body: postData);
|
||||
var body = god.deserialize(response.body)['body'];
|
||||
|
@ -74,7 +76,7 @@ main() {
|
|||
expect(body['nums'][2], equals(2));
|
||||
expect(body['map'] is Map, equals(true));
|
||||
expect(body['map']['foo'], equals({'bar': 'baz'}));
|
||||
}, skip: 'Array support via urlencoded is pending.');
|
||||
});
|
||||
});
|
||||
|
||||
group('JSON', () {
|
||||
|
|
Loading…
Reference in a new issue