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; return $middleWares;
} }
foreach ($node->getInterceptor() as $item) { foreach ($node->getInterceptor() as $item) {
$middleWares[] = $item; $middleWares[] = $item[0];
} }
return $middleWares; 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 . 'Interceptor', 'App\Http\Interceptor');
$annotation->registration_notes($prefix . 'Limits', 'App\Http\Limits'); $annotation->registration_notes($prefix . 'Limits', 'App\Http\Limits');
$router = $this;
$this->loadRouteDir(APP_PATH . '/routes'); $this->loadRouteDir(APP_PATH . '/routes');
} }
@@ -494,19 +493,31 @@ class Router extends Application implements RouterInterface
{ {
$files = glob($path . '/*'); $files = glob($path . '/*');
for ($i = 0; $i < count($files); $i++) { for ($i = 0; $i < count($files); $i++) {
try { if (is_dir($files[$i])) {
if (is_dir($files[$i])) { $this->loadRouteDir($files[$i]);
$this->loadRouteDir($files[$i]); } else {
} else { $this->loadRouterFile($files[$i]);
include_once "{$files[$i]}";
}
} catch (Exception $exception) {
$this->error($exception->getMessage());
} finally {
if (isset($exception)) {
unset($exception);
}
} }
} }
} }
/**
* @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' => [ 'events' => [
Event::SERVER_WORKER_START => function () { Event::SERVER_WORKER_START => function () {
$router = Snowflake::get()->router; $router = Snowflake::get()->router;
$router->loader(); $router->loadRouterSetting();
}, },
] ]
], ],