This commit is contained in:
2021-04-19 17:15:51 +08:00
parent 5dcce16aa0
commit 9604b9c1c5
+14 -14
View File
@@ -20,6 +20,7 @@ use Snowflake\Core\Json;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Throwable; use Throwable;
use validator\Validator;
use function Input; use function Input;
/** /**
@@ -514,10 +515,11 @@ class Node extends HttpService
*/ */
public function dispatch(): mixed public function dispatch(): mixed
{ {
$params = func_get_args();
if (empty($this->callback)) { if (empty($this->callback)) {
return Json::to(404, $this->errorMsg()); return Json::to(404, $this->errorMsg());
} }
return $this->httpFilter(...func_get_args()); return $this->httpFilter(...$params);
} }
@@ -528,22 +530,20 @@ class Node extends HttpService
private function httpFilter(): mixed private function httpFilter(): mixed
{ {
try { try {
$requestParam = func_get_args(); $param = func_get_args();
if ($this->handler instanceof Closure) { if ($this->handler instanceof Closure) {
return $this->runWith(...$requestParam); return $this->runWith(...$param);
} }
/** @var HttpFilter $filter */ /** @var HttpFilter $filter */
// $filter = Snowflake::app()->get('filter'); $filter = Snowflake::app()->get('filter');
// $validator = $filter->check(get_class($this->handler[0]), $this->handler[1]); $validator = $filter->check(get_class($this->handler[0]), $this->handler[1]);
// if (!($validator instanceof Validator)) { if (!($validator instanceof Validator)) {
// return $this->runWith(...$requestParam); return $this->runWith(...$param);
// } }
// if (!$validator->validation()) {
// if (!$validator->validation()) { return Json::to(5005, $validator->getError());
// return Json::to(5005, $validator->getError()); }
// } return $this->runWith(...$param);
return $this->runWith(...$requestParam);
} catch (Throwable $throwable) { } catch (Throwable $throwable) {
$this->addError($throwable, 'throwable'); $this->addError($throwable, 'throwable');