集成进lumen
This commit is contained in:
parent
caf6b8c8e5
commit
39ad209ab4
|
@ -27,7 +27,8 @@ class Client
|
||||||
'allow_redirects' => false,
|
'allow_redirects' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->http = new \GuzzleHttp\Client(array_merge($default,$config));
|
$this->http = new \GuzzleHttp\Client(array_merge($default, $config));
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +84,7 @@ class Client
|
||||||
return $body['result'];
|
return $body['result'];
|
||||||
|
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new RpcServerException('json decode error');
|
throw new RpcServerException('json decode error', -32700);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ClientServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
foreach ($config as $k => $item) {
|
foreach ($config as $k => $item) {
|
||||||
$this->app->singleton('rpc.' . $k, function () use ($k) {
|
$this->app->singleton('rpc.' . $k, function () use ($k) {
|
||||||
app('rpc')->endpoint($k);
|
return app('rpc')->endpoint($k);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class JsonRpcTool
|
||||||
$method = $request->input('method');
|
$method = $request->input('method');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = app('rpc')->call($method, $params);
|
$result = app('rpc.auth')->call($method, $params);
|
||||||
$view->share('result', json_encode($result, JSON_PRETTY_PRINT));
|
$view->share('result', json_encode($result, JSON_PRETTY_PRINT));
|
||||||
} catch (RpcServerException $exception) {
|
} catch (RpcServerException $exception) {
|
||||||
$view->share('error', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
|
$view->share('error', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Json Rpc Debug Tool</title>
|
<title>Json Rpc Debug Tool</title>
|
||||||
<link href="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link href="https://cdn.bootcss.com/highlight.js/7.3/styles/dark.css" rel="stylesheet">
|
<link href="https://cdn.bootcss.com/highlight.js/9.13.1/styles/ocean.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
<h5>Result:</h5>
|
<h5>Result:</h5>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<pre><code class="html">{{$result}}</code></pre>
|
<pre><code class="json">{{$result}}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@ -98,6 +98,7 @@
|
||||||
<script>window.jQuery || document.write('<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.slim.js"><\/script>')</script>
|
<script>window.jQuery || document.write('<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.slim.js"><\/script>')</script>
|
||||||
<script src="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>
|
<script src="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>
|
||||||
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
|
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/highlight.min.js"></script>
|
||||||
|
<script src="https://cdn.bootcss.com/highlight.js/9.13.1/languages/json.min.js"></script>
|
||||||
<script>hljs.initHighlightingOnLoad();</script>
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user