modify
This commit is contained in:
+12
-12
@@ -530,18 +530,11 @@ class Node extends HttpService
|
|||||||
private function httpFilter(): mixed
|
private function httpFilter(): mixed
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$dispatchParams = [\request()];
|
|
||||||
if ($this->handler instanceof Closure) {
|
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) {
|
} catch (Throwable $throwable) {
|
||||||
$this->addError($throwable, 'throwable');
|
$this->addError($throwable, 'throwable');
|
||||||
|
|
||||||
@@ -556,11 +549,18 @@ class Node extends HttpService
|
|||||||
* @return Validator|bool
|
* @return Validator|bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function getValidator(): Validator|bool
|
private function runValidator($dispatchParams): Validator|bool
|
||||||
{
|
{
|
||||||
/** @var HttpFilter $filter */
|
/** @var HttpFilter $filter */
|
||||||
$filter = Snowflake::app()->get('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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user