modify
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user