This commit is contained in:
2021-07-27 18:32:24 +08:00
parent d7f068fdbf
commit 2beaa726cd
2 changed files with 25 additions and 23 deletions
+8 -9
View File
@@ -103,16 +103,15 @@ class HTTPServerListener extends Abstracts\Server
try {
// defer(fn() => fire(Event::SYSTEM_RESOURCE_RELEASES));
[$sRequest, $sResponse] = $this->request($request, $response);
$node = $this->router->find_path($sRequest);
if ($node instanceof Node) {
$sResponse->send($node->dispatch());
} else {
$sResponse->send('404', 404);
}
$result = $this->router->dispatch($sRequest);
} catch (Error | Throwable $exception) {
$response->setHeader('Content-Type', 'text/html; charset=utf-8');
$response->setStatusCode(500);
$response->end(jTraceEx($exception, null, true));
$result = $this->router->exception($exception);
} finally {
if (!isset($sResponse)){
return;
}
$sResponse->send($result);
}
}