new version "(26) Reichshof": change return type from JSON array into JSON object {"output":[...], "return":..., "errorstack":[...]}

ENGINE-9
Roker 6 years ago
parent 7451b3f01b
commit 52268f6ed2

@ -10,7 +10,7 @@ public:
virtual ~Context() = default;
virtual bool verify_security_token(const std::string& token) const = 0;
virtual void augment(json_spirit::Value& value) = 0;
virtual void augment(json_spirit::Object& returnObject) = 0;
};
#endif // JSON_ADAPTER_CONTEXT_HH

@ -385,14 +385,16 @@ public:
// recursively extract the JSON parameters, call 'fn' and collect its return value
// and all output parameters into a tuple<> and return it as JSON array
js::Array out_params;
out_params.reserve( 1 + Helper::nr_of_output_params );
out_params.reserve( Helper::nr_of_output_params );
js::Value ret = Helper::call(fn, context, out_params, *p_params);
context->augment(ret); // used e.g. add some debug infos to the status return value
js::Object rs;
rs.emplace_back("outParams", std::move(out_params));
rs.emplace_back("return", std::move(ret));
out_params.push_back( ret );
return out_params;
context->augment(rs); // used e.g. add some debug infos to the status return value
return rs;
}
void setJavaScriptSignature(js::Object& o) const override

@ -90,8 +90,8 @@ const std::string server_version =
// "(22) Overath"; // add blacklist_retrieve(), rename identity_color() and outgoing_message_color() into ..._rating().
// "(23) Engelskirchen"; // fix JSON-19. Support "Bool" and "Language" as separate data types in JavaScript.
// "(24) Bielstein"; // add MIME_encrypt_message_ex() and MIME_decrypt_message_ex() as a HACK.
"(25) Gummersbach"; // JSON-22: add MIME_encrypt_message_for_self() and change API for encrypt_message_for_self().
// "(25) Gummersbach"; // JSON-22: add MIME_encrypt_message_for_self() and change API for encrypt_message_for_self().
"(26) Reichshof"; // change return type from JSON array into JSON object {"output":[...], "return":..., "errorstack":[...]}
typedef std::map<std::thread::id, PEP_SESSION> SessionRegistry;
@ -866,12 +866,11 @@ bool JsonAdapter::verify_security_token(const std::string& s) const
}
void JsonAdapter::augment(json_spirit::Value& value)
void JsonAdapter::augment(json_spirit::Object& returnObject)
{
js::Object o = value.get_obj();
PEP_SESSION session = from_json<PEP_SESSION>(value);
PEP_SESSION session = from_json<PEP_SESSION>(returnObject); // the parameter is not used :-D
auto errorstack = get_errorstack(session);
o.emplace_back( "errorstack", to_json(errorstack) );
returnObject.emplace_back( "errorstack", to_json(errorstack) );
}

@ -45,7 +45,7 @@ public:
// returns 'true' if 's' is the security token created by the function above.
virtual bool verify_security_token(const std::string& s) const override;
virtual void augment(json_spirit::Value& value) override;
virtual void augment(json_spirit::Object& returnObject) override;
static
unsigned apiVersion();

Loading…
Cancel
Save