改名
This commit is contained in:
@@ -394,17 +394,17 @@ class Router extends HttpService implements RouterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|null $explode
|
* @param array|null $explode
|
||||||
* @return Node|null
|
* @return Node|null
|
||||||
* 查找指定路由
|
* 查找指定路由
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function tree_search(?string $explode): ?Node
|
public function tree_search(?array $explode): ?Node
|
||||||
{
|
{
|
||||||
if (empty($this->nodes)) {
|
if (empty($this->nodes)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $this->nodes[$explode] ?? null;
|
$parent = $this->nodes[$explode] ?? null;
|
||||||
if (!($parent instanceof Node)) {
|
if (!($parent instanceof Node)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -425,7 +425,6 @@ class Router extends HttpService implements RouterInterface
|
|||||||
public function split($path): ?array
|
public function split($path): ?array
|
||||||
{
|
{
|
||||||
$path = $this->addPrefix() . '/' . ltrim($path, '/');
|
$path = $this->addPrefix() . '/' . ltrim($path, '/');
|
||||||
return [$path];
|
|
||||||
if ($path === '/') {
|
if ($path === '/') {
|
||||||
return ['/'];
|
return ['/'];
|
||||||
}
|
}
|
||||||
@@ -507,13 +506,10 @@ class Router extends HttpService implements RouterInterface
|
|||||||
{
|
{
|
||||||
$uri = $request->getUri();
|
$uri = $request->getUri();
|
||||||
if ($request->isMethod('OPTIONS')) {
|
if ($request->isMethod('OPTIONS')) {
|
||||||
$node = $this->tree_search('/*');
|
$node = $this->tree_search(['*']);
|
||||||
}
|
}
|
||||||
if (!isset($node)) {
|
if (!isset($node)) {
|
||||||
$node = $this->tree_search($uri->getPath());
|
$node = $this->tree_search($uri->getExplode());
|
||||||
}
|
|
||||||
if (!($node instanceof Node)) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user