mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Maintain compatibility for forwarded RPC responses:
Typically, an RPC response contains a `result` field, which contains details about the operation performed. For ease of parsing, forwarded responses must look like a non-forwarded response. In some instances the response was incorrectly composed, so that the actual `result` object would be encapsulated by an outer `result` object, breaking existing code. This commit, addresses this issue and correctly "folds" the `result` field, ensuring a consistent schema for responses.
This commit is contained in:
@@ -904,6 +904,17 @@ ServerHandlerImp::processRequest(
|
||||
reply.append(std::move(r));
|
||||
else
|
||||
reply = std::move(r);
|
||||
|
||||
if (reply.isMember(jss::result) &&
|
||||
reply[jss::result].isMember(jss::result))
|
||||
{
|
||||
reply = reply[jss::result];
|
||||
if (reply.isMember(jss::status))
|
||||
{
|
||||
reply[jss::result][jss::status] = reply[jss::status];
|
||||
reply.removeMember(jss::status);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto response = to_string(reply);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user