This commit is contained in:
2021-03-19 18:33:36 +08:00
parent 884734dafa
commit c925fead2d
+10 -12
View File
@@ -575,27 +575,25 @@ class Node extends HttpService
*/ */
private function httpFilter(): mixed private function httpFilter(): mixed
{ {
if (!is_array($this->handler)) {
return $this->runWith(...func_get_args());
}
try { try {
[$class, $method] = $this->handler; if (!is_array($this->handler)) {
return $this->runWith(...func_get_args());
}
/** @var HttpFilter $filter */ /** @var HttpFilter $filter */
$filter = Snowflake::app()->get('filter'); $filter = Snowflake::app()->get('filter');
$validator = $filter->check(get_class($class), $method); $validator = $filter->check(get_class($this->handler[0]), $this->handler[1]);
if ($validator instanceof Validator && !$validator->validation()) { if (!($validator instanceof Validator)) {
response()->statusCode = 401; return $this->runWith(...func_get_args());
}
if (!$validator->validation()) {
var_dump($validator->getError());
return Json::to(401, $validator->getError()); return Json::to(401, $validator->getError());
} }
return $this->runWith(...func_get_args());
} catch (Throwable $throwable) { } catch (Throwable $throwable) {
$this->error($throwable->getMessage()); $this->error($throwable->getMessage());
return Json::to(401, $throwable->getMessage()); return Json::to(401, $throwable->getMessage());
} }
return $this->runWith(...func_get_args());
} }