This commit is contained in:
2020-09-01 03:38:27 +08:00
parent fd40fe922b
commit caa58018c1
3 changed files with 26 additions and 15 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ class Middleware
return $middleWares;
}
foreach ($node->getInterceptor() as $item) {
$middleWares[] = $item;
$middleWares[] = $item[0];
}
return $middleWares;
}
+24 -13
View File
@@ -481,7 +481,6 @@ class Router extends Application implements RouterInterface
$annotation->registration_notes($prefix . 'Interceptor', 'App\Http\Interceptor');
$annotation->registration_notes($prefix . 'Limits', 'App\Http\Limits');
$router = $this;
$this->loadRouteDir(APP_PATH . '/routes');
}
@@ -494,19 +493,31 @@ class Router extends Application implements RouterInterface
{
$files = glob($path . '/*');
for ($i = 0; $i < count($files); $i++) {
try {
if (is_dir($files[$i])) {
$this->loadRouteDir($files[$i]);
} else {
include_once "{$files[$i]}";
}
} catch (Exception $exception) {
$this->error($exception->getMessage());
} finally {
if (isset($exception)) {
unset($exception);
}
if (is_dir($files[$i])) {
$this->loadRouteDir($files[$i]);
} else {
$this->loadRouterFile($files[$i]);
}
}
}
/**
* @param $files
* @throws Exception
*/
private function loadRouterFile($files)
{
try {
$router = $this;
include_once "{$files}";
} catch (Exception $exception) {
$this->error($exception->getMessage());
} finally {
if (isset($exception)) {
unset($exception);
}
}
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ return [
'events' => [
Event::SERVER_WORKER_START => function () {
$router = Snowflake::get()->router;
$router->loader();
$router->loadRouterSetting();
},
]
],