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.', '127.0.0.',
'192.168.', '192.168.',
'10.0.', '10.0.',
'172.19.'
])) { ])) {
return true; return true;
} }

View File

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

View File

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

View File

@ -68,9 +68,9 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="inputAddress">Params</label> <label for="inputAddress">Paramsjson 数组)</label>
<input type="text" class="form-control" name="params" id="params" placeholder="逗号分隔" <div id="editor" style="height: 300px">{{$params}}</div>
value="{{$params}}"> <input type="hidden" name="params" id="params" value="{{$params}}">
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">Request</button> <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/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 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> <script>hljs.initHighlightingOnLoad();</script>
</body> </body>
</html> </html>