qqq
This commit is contained in:
@@ -197,9 +197,6 @@ class Router
|
|||||||
$scanner->parse('App');
|
$scanner->parse('App');
|
||||||
|
|
||||||
$this->read_dir_file(APP_PATH . 'routes');
|
$this->read_dir_file(APP_PATH . 'routes');
|
||||||
|
|
||||||
$router = Kiri::getDi()->get(DataGrip::class)->get(ROUTER_TYPE_HTTP);
|
|
||||||
$router->reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-21
@@ -39,25 +39,6 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
private array $methods = [];
|
private array $methods = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
|
||||||
public function reset(): void
|
|
||||||
{
|
|
||||||
$middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string $method
|
|
||||||
* @var HashMap $handlers
|
|
||||||
*/
|
|
||||||
foreach ($this->methods as $method => $handler) {
|
|
||||||
$middleware = $middlewareManager->get($handler->getClass(), $handler->getMethod());
|
|
||||||
|
|
||||||
$this->methods[$method] = new HttpRequestHandler($middleware, $handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
@@ -209,14 +190,14 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
* @return Handler|null
|
* @return Handler|null
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function query(string $path, string $method): ?HttpRequestHandler
|
public function query(string $path, string $method): ?Handler
|
||||||
{
|
{
|
||||||
if ($method === 'OPTIONS') {
|
if ($method === 'OPTIONS') {
|
||||||
$path = '/*';
|
$path = '/*';
|
||||||
}
|
}
|
||||||
$parent = $this->methods[$method . '_' . $path] ?? null;
|
$parent = $this->methods[$method . '_' . $path] ?? null;
|
||||||
if ($parent === null) {
|
if ($parent === null) {
|
||||||
return new HttpRequestHandler([], new Handler([di(NotFoundController::class), 'fail'], []));
|
return new Handler([di(NotFoundController::class), 'fail'], []);
|
||||||
}
|
}
|
||||||
return $parent;
|
return $parent;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user