This commit is contained in:
2021-03-08 16:33:10 +08:00
parent f065b1c3b1
commit 0c2015e084
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -44,7 +44,11 @@ class OnPacket extends Callback
if (($node = $router->find_path($request)) === null) {
return $server->sendto($host, $port, Json::encode(['state' => 404]));
}
return $server->sendto($host, $port, $node->dispatch());
$dispatch = $node->dispatch();
if (!is_string($dispatch)) $dispatch = Json::encode($dispatch);
return $server->sendto($host, $port, $dispatch);
} catch (\Throwable $exception) {
$response = Json::encode(['state' => 500, 'message' => $exception->getMessage()]);