改名
This commit is contained in:
@@ -10,7 +10,6 @@ use Annotation\Route\RpcProducer;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\Abstracts\HttpService;
|
use HttpServer\Abstracts\HttpService;
|
||||||
use HttpServer\Exception\RequestException;
|
|
||||||
use HttpServer\Http\Request;
|
use HttpServer\Http\Request;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
@@ -123,12 +122,22 @@ class Node extends HttpService
|
|||||||
} else {
|
} else {
|
||||||
$callback = $this->injectClosureMiddleware($manager, $handler);
|
$callback = $this->injectClosureMiddleware($manager, $handler);
|
||||||
}
|
}
|
||||||
$handlerProviders = di(HandlerProviders::class);
|
$this->getHandlerProviders()->add($this->method, $this->sourcePath, $callback);
|
||||||
$handlerProviders->add($this->method, $this->sourcePath, $callback);
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return HandlerProviders
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
private function getHandlerProviders(): HandlerProviders
|
||||||
|
{
|
||||||
|
return Snowflake::getDi()->get(HandlerProviders::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $manager
|
* @param $manager
|
||||||
* @param $handler
|
* @param $handler
|
||||||
@@ -363,9 +372,9 @@ class Node extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function dispatch(): mixed
|
public function dispatch(): mixed
|
||||||
{
|
{
|
||||||
$handlerProviders = di(HandlerProviders::class)->get($this->sourcePath, $this->method);
|
$handlerProviders = $this->getHandlerProviders()->get($this->sourcePath, $this->method);
|
||||||
if (empty($handlerProviders)) {
|
if (empty($handlerProviders)) {
|
||||||
throw new RequestException('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', 404);
|
return '<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>';
|
||||||
}
|
}
|
||||||
return call_user_func($handlerProviders, \request());
|
return call_user_func($handlerProviders, \request());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user