This commit is contained in:
2021-02-23 17:19:46 +08:00
parent 21bdf32fc3
commit 31d5024663
10 changed files with 41 additions and 26 deletions
+5 -2
View File
@@ -9,6 +9,7 @@ use Closure;
use HttpServer\Controller;
use HttpServer\Http\Context;
use HttpServer\Http\Request;
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake;
/**
@@ -27,10 +28,11 @@ class Dispatch
* @param $handler
* @param $request
* @return static
* @throws ComponentException
*/
public static function create($handler, $request): static
{
$class = new static();
$class = objectPool(get_called_class());
$class->handler = $handler;
$class->request = $request;
if ($handler instanceof Closure) {
@@ -53,10 +55,11 @@ class Dispatch
/**
* 设置作用域
* @throws ComponentException
*/
protected function bind()
{
$class = $this->bindRequest(new Controller());
$class = $this->bindRequest(objectPool(Controller::class));
$this->handler = Closure::bind($this->handler, $class);
}