改名
This commit is contained in:
@@ -314,19 +314,21 @@ class Node
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param RequestInterface $request
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws RequestException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function dispatch(): mixed
|
public function dispatch(RequestInterface $request): mixed
|
||||||
{
|
{
|
||||||
if (!in_array(request()->getMethod(), $this->method)) {
|
if (!in_array($request->getMethod(), $this->method)) {
|
||||||
throw new RequestException('<h2>HTTP 405 Method allow</h2><hr><i>Powered by Swoole</i>', 405);
|
throw new RequestException('<h2>HTTP 405 Method allow</h2><hr><i>Powered by Swoole</i>', 405);
|
||||||
}
|
}
|
||||||
$handlerProviders = HandlerProviders::get($this->sourcePath, request()->getMethod());
|
$handlerProviders = HandlerProviders::get($this->sourcePath, $request->getMethod());
|
||||||
if (empty($handlerProviders)) {
|
if (empty($handlerProviders)) {
|
||||||
throw new RequestException('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', 404);
|
throw new RequestException('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', 404);
|
||||||
}
|
}
|
||||||
return $handlerProviders->interpreter();
|
return $handlerProviders->interpreter($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,12 +127,12 @@ class Pipeline
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param $request
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function interpreter(): mixed
|
public function interpreter($request): mixed
|
||||||
{
|
{
|
||||||
return call_user_func($this->pipeline, request());
|
return call_user_func($this->pipeline, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,12 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect
|
|||||||
{
|
{
|
||||||
// TODO: Implement onRequest() method.
|
// TODO: Implement onRequest() method.
|
||||||
try {
|
try {
|
||||||
$node = $this->router->Branch_search(\Server\Constrict\Request::create($request));
|
$request = \Server\Constrict\Request::create($request);
|
||||||
|
$node = $this->router->Branch_search($request);
|
||||||
if (!($node instanceof Node)) {
|
if (!($node instanceof Node)) {
|
||||||
throw new RequestException('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', 404);
|
throw new RequestException('<h2>HTTP 404 Not Found</h2><hr><i>Powered by Swoole</i>', 404);
|
||||||
}
|
}
|
||||||
if (!(($responseData = $node->dispatch()) instanceof ResponseInterface)) {
|
if (!(($responseData = $node->dispatch($request)) instanceof ResponseInterface)) {
|
||||||
$responseData = $this->transferToResponse($responseData);
|
$responseData = $this->transferToResponse($responseData);
|
||||||
}
|
}
|
||||||
} catch (Error | \Throwable $exception) {
|
} catch (Error | \Throwable $exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user