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:
CJ Cobb
2021-03-29 16:51:41 -04:00
committed by Nik Bougalis
parent 9c8caddc5a
commit 8579eb0c19

View File

@@ -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);