This commit is contained in:
as2252258@163.com
2021-04-21 01:40:00 +08:00
parent 2a4cca4b61
commit 52886be6aa
2 changed files with 8 additions and 5 deletions
+5 -1
View File
@@ -36,7 +36,11 @@ class Dispatch
{ {
$class = new static(); $class = new static();
$class->handler = $handler; $class->handler = $handler;
$class->request = $request; $dispatchParam = Context::getContext('dispatch-param');
if (empty($dispatchParam)) {
$dispatchParam = [\request()];
}
$class->request = $dispatchParam;
if ($handler instanceof Closure) { if ($handler instanceof Closure) {
$class->bind(); $class->bind();
} }
+3 -4
View File
@@ -17,6 +17,7 @@ use HttpServer\Controller;
use HttpServer\Http\Context; use HttpServer\Http\Context;
use HttpServer\Http\Request; use HttpServer\Http\Request;
use HttpServer\HttpFilter; use HttpServer\HttpFilter;
use HttpServer\Route\Dispatch\Dispatch;
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\Pure;
use Snowflake\Core\Json; use Snowflake\Core\Json;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -126,10 +127,8 @@ class Node extends HttpService
public function createDispatch(): Closure public function createDispatch(): Closure
{ {
return function () { return function () {
$dispatchParam = Context::getContext('dispatch-param'); return Dispatch::create($this->handler,\request())->dispatch();
if (empty($dispatchParam)) {
$dispatchParam = [\request()];
}
return call_user_func($this->handler, ...$dispatchParam); return call_user_func($this->handler, ...$dispatchParam);
}; };
} }