This commit is contained in:
候学杰 2019-01-25 17:17:46 +08:00
parent 487316deac
commit d8c4763479
4 changed files with 18 additions and 11 deletions

View File

@ -48,6 +48,7 @@ class Security
'127.0.0.',
'192.168.',
'10.0.',
'172.19.'
])) {
return true;
}

View File

@ -31,9 +31,9 @@ class JsonRpcServer extends JsonRpcBase
public function handler()
{
if ($this->request->getContentType() != 'json') {
return $this->error(self::Rpc_Error_Invalid_Request);
}
// if ($this->request->getContentType() != 'json') {
// return $this->error(self::Rpc_Error_Invalid_Request);
// }
try {

View File

@ -35,12 +35,9 @@ class JsonRpcTool
*/
$view = view();
$params = json_decode($request->input('params'), true);
$params = json_decode($request->input('params',"[\r\n]"), true);
$method = $request->input('method');
if ($request->method() == Request::METHOD_POST) {
try {
$result = app('rpc.'.$this->config['name'])->call($method, $params);
$view->share('result', json_encode($result, JSON_PRETTY_PRINT));
@ -52,7 +49,7 @@ class JsonRpcTool
$view->share('method',$method);
$view->share('endpoint', $this->getEndpoint());
$view->share('methods', $methods);
$view->share('params', json_encode($params));
$view->share('params', json_encode($params,JSON_PRETTY_PRINT));
foreach ($methods as $name => $class) {
$desc[$name] = $this->desc($class[0], $class[1]);

View File

@ -68,9 +68,9 @@
<div class="form-row">
<div class="form-group col-md-12">
<label for="inputAddress">Params</label>
<input type="text" class="form-control" name="params" id="params" placeholder="逗号分隔"
value="{{$params}}">
<label for="inputAddress">Paramsjson 数组)</label>
<div id="editor" style="height: 300px">{{$params}}</div>
<input type="hidden" name="params" id="params" value="{{$params}}">
</div>
</div>
<button type="submit" class="btn btn-primary">Request</button>
@ -99,6 +99,15 @@
<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/languages/json.min.js"></script>
<script src="https://cdn.bootcss.com/ace/1.4.2/ace.js"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/json");
editor.on('change',function(e){
$('#params').val(editor.getValue())
})
</script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>