From eb05e297627cb0aeddfc260d927b3e552de3d506 Mon Sep 17 00:00:00 2001 From: dongwei <838456736@qq.com> Date: Thu, 24 Jan 2019 14:11:50 +0800 Subject: [PATCH 1/5] change log --- config/rpc.php | 2 +- src/Providers/BaseServiceProvider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/rpc.php b/config/rpc.php index 5b859c1..906f90a 100644 --- a/config/rpc.php +++ b/config/rpc.php @@ -35,7 +35,7 @@ return [ ], 'api' => [ 'local' => true, - 'base_uri' => env('RPC_API_URI','http://api.dev.haowumc.com'), + 'base_uri' => env('RPC_API_URI','http://sapi.dev.haowumc.com'), ], 'op' => [ 'local' => true, diff --git a/src/Providers/BaseServiceProvider.php b/src/Providers/BaseServiceProvider.php index f662a43..7a459bd 100644 --- a/src/Providers/BaseServiceProvider.php +++ b/src/Providers/BaseServiceProvider.php @@ -30,7 +30,7 @@ class BaseServiceProvider extends ServiceProvider $this->setupConfig(); $this->app->singleton("rpc.logger", function () { $config = config('rpc'); - $stream = new StreamHandler($this->app->storagePath() . $config['log_path']); + $stream = new StreamHandler($config['log_path']); $stream->setFormatter(new $config['log_formatter']()); $logger = new Logger('RPC.LOGGER'); return $logger->pushHandler($stream); From 74986304bf9207ef122a490285276182b13de4fa Mon Sep 17 00:00:00 2001 From: dongwei <838456736@qq.com> Date: Thu, 24 Jan 2019 14:25:56 +0800 Subject: [PATCH 2/5] del error doc --- src/Server/JsonRpcMethod.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Server/JsonRpcMethod.php b/src/Server/JsonRpcMethod.php index 4f280bc..a5ca9ef 100644 --- a/src/Server/JsonRpcMethod.php +++ b/src/Server/JsonRpcMethod.php @@ -25,11 +25,6 @@ class JsonRpcMethod extends JsonRpcBase ]; } - /** - * @param $code - * @param $msg - * @return array - */ public function error($code, $msg) { From b47df658829cbdf97f2127378bcbf9c3ad158277 Mon Sep 17 00:00:00 2001 From: dongwei <838456736@qq.com> Date: Thu, 24 Jan 2019 15:25:16 +0800 Subject: [PATCH 3/5] add readme's doc info --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 1af5a62..a26eb71 100644 --- a/README.md +++ b/README.md @@ -170,3 +170,19 @@ http://host/rpc/doc.html 文档地址 严格使用系统定义错误码 详见json-rpc/src/Server/JsonRpcBase.php ###更新日志 + +###文档注释格式 +``` + /** + * @title 用户登录API + * @url https://wwww.baidu.com/login + * @method POST + * @param 类型 字段名称 描述 默认 是否必须 + * @param string password 密码 空 必须 + * @code 1 成功 + * @code 2 失败 + * @return int code 状态码(具体参见状态码说明) + * @return string msg 提示信息 + */ + +``` From d8c476347964a1cdfad9f9d57060eaf7eb9332d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Fri, 25 Jan 2019 17:17:46 +0800 Subject: [PATCH 4/5] tool --- src/Middleware/Security.php | 1 + src/Server/JsonRpcServer.php | 6 +++--- src/Server/JsonRpcTool.php | 7 ++----- src/views/tool.blade.php | 15 ++++++++++++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Middleware/Security.php b/src/Middleware/Security.php index 5007b02..6d2eabc 100644 --- a/src/Middleware/Security.php +++ b/src/Middleware/Security.php @@ -48,6 +48,7 @@ class Security '127.0.0.', '192.168.', '10.0.', + '172.19.' ])) { return true; } diff --git a/src/Server/JsonRpcServer.php b/src/Server/JsonRpcServer.php index 017fa7c..ebda98d 100644 --- a/src/Server/JsonRpcServer.php +++ b/src/Server/JsonRpcServer.php @@ -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 { diff --git a/src/Server/JsonRpcTool.php b/src/Server/JsonRpcTool.php index afbbadb..258253d 100644 --- a/src/Server/JsonRpcTool.php +++ b/src/Server/JsonRpcTool.php @@ -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]); diff --git a/src/views/tool.blade.php b/src/views/tool.blade.php index 5db66da..9f29510 100644 --- a/src/views/tool.blade.php +++ b/src/views/tool.blade.php @@ -68,9 +68,9 @@
- - + +
{{$params}}
+
@@ -99,6 +99,15 @@ + + \ No newline at end of file From 08bcc2a139d3c20279ceac3e45c114d1ae83f234 Mon Sep 17 00:00:00 2001 From: dongwei <838456736@qq.com> Date: Fri, 25 Jan 2019 17:28:33 +0800 Subject: [PATCH 5/5] add doc link --- src/views/tool.blade.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/views/tool.blade.php b/src/views/tool.blade.php index 9f29510..8f61ba6 100644 --- a/src/views/tool.blade.php +++ b/src/views/tool.blade.php @@ -23,17 +23,17 @@