Commit 5498bd16 authored by Tristan Cavelier's avatar Tristan Cavelier

rest command resolver behavior bug fix

In this example, status was not considered at all:

    command.success({"status": 201});
parent 4d825607
...@@ -11,9 +11,11 @@ function restCommandResolver(param, args) { ...@@ -11,9 +11,11 @@ function restCommandResolver(param, args) {
{}, {},
// 1 - default values // 1 - default values
{}, {},
// 2 - status parameter // 2 - status property
{}, {},
// 3 - never change // 3 - status parameter
{},
// 4 - never change
{"result": "success", "method": param.method} {"result": "success", "method": param.method}
]; ];
args = Array.prototype.slice.call(args); args = Array.prototype.slice.call(args);
...@@ -42,8 +44,8 @@ function restCommandResolver(param, args) { ...@@ -42,8 +44,8 @@ function restCommandResolver(param, args) {
current_priority.statusText = constants.http_status_text.ok; current_priority.statusText = constants.http_status_text.ok;
} }
// priority 2 - status parameter // priority 3 - status parameter
current_priority = priority[2]; current_priority = priority[3];
// parsing first parameter if is not an object // parsing first parameter if is not an object
if (typeof arg !== 'object' || arg === null || Array.isArray(arg)) { if (typeof arg !== 'object' || arg === null || Array.isArray(arg)) {
if (arg !== undefined) { if (arg !== undefined) {
...@@ -52,11 +54,14 @@ function restCommandResolver(param, args) { ...@@ -52,11 +54,14 @@ function restCommandResolver(param, args) {
arg = args.shift(); arg = args.shift();
} }
// priority 0 - custom values
current_priority = priority[0];
// parsing second parameter if is an object // parsing second parameter if is an object
if (typeof arg === 'object' && arg !== null && !Array.isArray(arg)) { if (typeof arg === 'object' && arg !== null && !Array.isArray(arg)) {
// priority 0 - custom values
dictUpdate(current_priority, arg); dictUpdate(current_priority, arg);
// priority 2 - status property
if (arg.hasOwnProperty("status") || arg.hasOwnProperty("statusText")) {
priority[2].status = arg.statusText || arg.status;
}
} }
// merge priority dicts // merge priority dicts
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment