改名
This commit is contained in:
+1
-4
@@ -53,10 +53,7 @@ class Client extends Component
|
|||||||
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
return $this->addError($this->client->errMsg . '(' . $this->client->errCode . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->client->recv();
|
if (is_bool($unpack = Json::decode($this->client->recv()))) {
|
||||||
$this->client->close();
|
|
||||||
|
|
||||||
if (is_bool($unpack = Json::decode($response))) {
|
|
||||||
return $this->addError('Service return data format error(500)');
|
return $this->addError('Service return data format error(500)');
|
||||||
}
|
}
|
||||||
return $unpack;
|
return $unpack;
|
||||||
|
|||||||
+7
-3
@@ -70,10 +70,14 @@ class Service extends Component
|
|||||||
try {
|
try {
|
||||||
/** @var Request $request */
|
/** @var Request $request */
|
||||||
$request = Context::getContext('request');
|
$request = Context::getContext('request');
|
||||||
if (($node = router()->find_path($this->replace($request, $service))) === null) {
|
if (($node = router()->find_path(Service::replace($request, $service))) === null) {
|
||||||
throw new Exception('Cmd not find.');
|
throw new Exception('Cmd not find.');
|
||||||
}
|
}
|
||||||
return Json::encode($node->dispatch());
|
$response = $node->dispatch();
|
||||||
|
if (is_string($response)) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
return Json::encode($response);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->addError($exception);
|
$this->addError($exception);
|
||||||
return Json::encode(['state' => 'fail', 'message' => $exception->getMessage()]);
|
return Json::encode(['state' => 'fail', 'message' => $exception->getMessage()]);
|
||||||
@@ -88,7 +92,7 @@ class Service extends Component
|
|||||||
* @return Request
|
* @return Request
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function replace(Request $request, array $service): Request
|
public static function replace(Request $request, array $service): Request
|
||||||
{
|
{
|
||||||
$body = $request->params->getBodyAndClear();
|
$body = $request->params->getBodyAndClear();
|
||||||
if (is_null($serialize = unserialize($body))) {
|
if (is_null($serialize = unserialize($body))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user