This commit is contained in:
2020-09-03 15:50:40 +08:00
parent e3ed74aa2f
commit 6504ae700d
+3 -8
View File
@@ -52,21 +52,16 @@ class Router extends Application implements RouterInterface
if (!isset($this->nodes[$method])) { if (!isset($this->nodes[$method])) {
$this->nodes[$method] = []; $this->nodes[$method] = [];
} }
list($first, $explode) = $this->split($path); list($first, $explode) = $this->split($path);
$parent = $this->nodes[$method][$first] ?? null; $parent = $this->nodes[$method][$first] ?? null;
if ($handler instanceof \Closure) {
$handler = Closure::bind($handler, new Controller());
}
if (empty($parent)) { if (empty($parent)) {
$parent = $this->NodeInstance($first, 0, $method); $parent = $this->NodeInstance($first, 0, $method);
$this->nodes[$method][$first] = $parent; $this->nodes[$method][$first] = $parent;
} }
if ($first === '/') { if ($first !== '/') {
return $parent->bindHandler($handler); $parent = $this->bindNode($parent, $explode, $method);
} }
return $this->bindNode($parent, $explode, $method) return $parent->bindHandler($handler);
->bindHandler($handler);
} }
/** /**