This commit is contained in:
as2252258@163.com
2021-04-21 01:51:28 +08:00
parent 1ee39fee64
commit 69908bcf72
+12 -12
View File
@@ -530,18 +530,11 @@ class Node extends HttpService
private function httpFilter(): mixed
{
try {
$dispatchParams = [\request()];
if ($this->handler instanceof Closure) {
return call_user_func($this->handler, ...$dispatchParams);
return call_user_func($this->handler, \request());
} else {
return $this->runValidator([\request()]);
}
$validator = $this->getValidator();
if (!($validator instanceof Validator)) {
return call_user_func($this->callback, ...$dispatchParams);
}
if ($validator->validation()) {
return call_user_func($this->callback, ...$dispatchParams);
}
return Json::to(5005, $validator->getError());
} catch (Throwable $throwable) {
$this->addError($throwable, 'throwable');
@@ -556,11 +549,18 @@ class Node extends HttpService
* @return Validator|bool
* @throws Exception
*/
private function getValidator(): Validator|bool
private function runValidator($dispatchParams): Validator|bool
{
/** @var HttpFilter $filter */
$filter = Snowflake::app()->get('filter');
return $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)) {
return call_user_func($this->callback, ...$dispatchParams);
}
if ($validator->validation()) {
return call_user_func($this->callback, ...$dispatchParams);
}
return Json::to(5005, $validator->getError());
}