mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-27 23:25:53 +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;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ public:
|
||||
if (!id.is_null())
|
||||
error["id"] = id;
|
||||
error["request"] = request;
|
||||
response = error;
|
||||
result = error;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user