This commit is contained in:
2021-09-18 10:48:25 +08:00
parent 13fadb5ffc
commit 1956cc64ae
+9
View File
@@ -8,6 +8,7 @@ use Closure;
use Exception; use Exception;
use Http\Abstracts\HttpService; use Http\Abstracts\HttpService;
use Http\Controller; use Http\Controller;
use Http\Handler\Abstracts\HandlerManager;
use Http\IInterface\MiddlewareInterface; use Http\IInterface\MiddlewareInterface;
use Http\IInterface\RouterInterface; use Http\IInterface\RouterInterface;
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\Pure;
@@ -103,6 +104,14 @@ class Router extends HttpService implements RouterInterface
if ($handler instanceof Closure) { if ($handler instanceof Closure) {
$handler = Closure::bind($handler, di(Controller::class)); $handler = Closure::bind($handler, di(Controller::class));
} }
$path = $this->addPrefix() . '/' . ltrim($path, '/');
HandlerManager::add($path, $method, $handler);
return null;
return $this->tree($path, $handler, $method); return $this->tree($path, $handler, $method);
} }