mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-26 14:45:52 +00:00
Unwrap result when forwarding (#78)
* fix error formatting for forwarded responses * unwrap result when forwarding successful responses
This commit is contained in:
@@ -166,12 +166,19 @@ buildResponse(Context const& ctx)
|
||||
{
|
||||
if (shouldForwardToRippled(ctx))
|
||||
{
|
||||
auto res = ctx.balancer->forwardToRippled(ctx.params, ctx.clientIp);
|
||||
boost::json::object toForward = ctx.params;
|
||||
toForward["command"] = ctx.method;
|
||||
|
||||
auto res = ctx.balancer->forwardToRippled(toForward, ctx.clientIp);
|
||||
|
||||
ctx.counters.rpcForwarded(ctx.method);
|
||||
|
||||
if (!res)
|
||||
return Status{Error::rpcFAILED_TO_FORWARD};
|
||||
|
||||
if (res->contains("result") && res->at("result").is_object())
|
||||
return res->at("result").as_object();
|
||||
|
||||
return *res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user