This commit is contained in:
2020-12-02 11:08:05 +08:00
parent e116ad5446
commit 740388a693
+8 -13
View File
@@ -476,22 +476,17 @@ class Router extends Application implements RouterInterface
public function dispatch() public function dispatch()
{ {
try { try {
if ($this->reading) { if (!($node = $this->find_path(\request()))) {
$response = send(self::NOT_FOUND, 502); return send(self::NOT_FOUND, 404);
} else if (!($node = $this->find_path(\request()))) { }
$response = send(self::NOT_FOUND, 404); send($node->dispatch(), 200);
} else { if ($node->hasAfter()) {
$response = send($node->dispatch(), 200); $node->afterDispatch(\request());
} }
} catch (ExitException $exception) { } catch (ExitException $exception) {
$response = send($exception->getMessage(), $exception->getCode()); send($exception->getMessage(), $exception->getCode());
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
$response = send($this->exception($exception), 200); send($this->exception($exception), 200);
} finally {
if (!isset($node) || !($node instanceof Node)) {
return;
}
$node->hasAfter() && $node->afterDispatch($response ?? null);
} }
} }