This commit is contained in:
as2252258@163.com
2021-03-06 19:03:37 +08:00
parent 85c0631f10
commit 419d966984
+13 -7
View File
@@ -478,14 +478,20 @@ class Router extends HttpService implements RouterInterface
*/ */
public function dispatch(): mixed public function dispatch(): mixed
{ {
if (!($node = $this->find_path(\request()))) { try {
return send(self::NOT_FOUND); if (!($node = $this->find_path(\request()))) {
return send(self::NOT_FOUND);
}
send($response = $node->dispatch(), 200);
if (!$node->hasAfter()) {
return null;
}
return $node->afterDispatch($response);
} catch (\Throwable $exception) {
$this->addError($exception);
return send($exception->getMessage(), 200);
} }
send($response = $node->dispatch(), 200);
if (!$node->hasAfter()) {
return null;
}
return $node->afterDispatch($response);
} }