This commit is contained in:
2021-04-22 14:40:17 +08:00
parent 7024e07115
commit 47cf262128
+5
View File
@@ -6,6 +6,7 @@ namespace HttpServer\Route;
use Closure;
use Exception;
use HttpServer\Abstracts\HttpService;
use HttpServer\Controller;
use HttpServer\Http\Request;
use HttpServer\IInterface\Middleware;
use HttpServer\IInterface\RouterInterface;
@@ -108,6 +109,10 @@ class Router extends HttpService implements RouterInterface
$this->nodes[$method] = [];
}
if ($handler instanceof Closure) {
$handler = Closure::bind($handler, new Controller());
}
if ($this->useTree == ROUTER_TREE) {
return $this->tree($path, $handler, $method);
} else {