This commit is contained in:
2021-02-22 17:44:24 +08:00
parent 3b09b9a308
commit 2d1f83cf09
34 changed files with 732 additions and 222 deletions
+11 -1
View File
@@ -14,6 +14,7 @@ use JetBrains\PhpStorm\Pure;
use ReflectionException;
use Snowflake\Core\Json;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake;
use Swoole\Coroutine;
@@ -56,6 +57,16 @@ class Node extends HttpService
private array $_after = [];
private array $_limits = [];
/**
* @throws ComponentException
* @throws Exception
*/
public function afterInit()
{
listen(Event::SERVER_AFTER_WORKER_START, [$this, 'restructure']);
}
/**
* @param $handler
* @return Node
@@ -450,7 +461,6 @@ class Node extends HttpService
*/
public function dispatch(): mixed
{
$this->restructure();
if (empty($this->callback)) {
return Json::to(404, $node->_error ?? 'Page not found.');
}