JsonResponse
This commit is contained in:
parent
ffca2c303b
commit
d5470ca40d
|
@ -17,29 +17,23 @@ class JsonRpcMethod
|
|||
|
||||
public function response($result)
|
||||
{
|
||||
return JsonResponse::create([
|
||||
return [
|
||||
'jsonrpc' => '2.0',
|
||||
'result' => $result,
|
||||
'id' => $this->id
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $code
|
||||
* @param $msg
|
||||
* @return static
|
||||
*/
|
||||
public function error($code, $msg)
|
||||
{
|
||||
return JsonResponse::create([
|
||||
return [
|
||||
'jsonrpc' => '2.0',
|
||||
'error' => [
|
||||
'code' => $code,
|
||||
'message' => is_array($msg) ? json_encode($msg) : $msg,
|
||||
],
|
||||
'id' => $this->id
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -65,8 +65,9 @@ class JsonRpcServer
|
|||
|
||||
app('rpc.logger')->info('server', [$id, $class,$method, $params, $this->request->header('client_app'), $this->request->header('client_addr'), $this->request->header('client_host')]);
|
||||
$ret = call_user_func_array([(new $class($id, $this->request)), $function], $params);
|
||||
app('rpc.logger')->info('server_result', [$id, \GuzzleHttp\json_decode($ret, true)]);
|
||||
return $ret;
|
||||
app('rpc.logger')->info('server_result', [$id, $ret]);
|
||||
|
||||
return JsonResponse::create($ret);
|
||||
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return $this->error(self::Rpc_Error_Parse_Error);
|
||||
|
|
Loading…
Reference in New Issue
Block a user