From 5a1aa2d60f5f8451357b5bd96c9a5ddef4226c66 Mon Sep 17 00:00:00 2001 From: whwyy Date: Wed, 24 Jun 2026 20:56:50 +0800 Subject: [PATCH] eee --- src/Router.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Router.php b/src/Router.php index 60af75a..04fba0a 100644 --- a/src/Router.php +++ b/src/Router.php @@ -367,6 +367,42 @@ class Router $routeCount = count($router->dump()); \Kiri::getLogger()->info("Annotation route rebuild: {$classCount} classes processed, {$dispatchCount} annotation routes dispatched, {$routeCount} total routes, {$errorCount} errors"); + + // 搜索特定路径的诊断日志,方便排查 404 问题 + $searchPaths = ['/headers']; + foreach ($searchPaths as $searchPath) { + $found = []; + foreach ($manifestEntries as $path => $entry) { + $classes = is_array($entry) && isset($entry['classes']) ? $entry['classes'] : []; + foreach ($classes as $class) { + try { + $reflect = $container->getReflectionClass($class); + foreach ($reflect->getMethods() as $method) { + foreach ($method->getAttributes() as $attr) { + if (in_array($attr->getName(), [ + \Kiri\Router\Annotate\Get::class, + \Kiri\Router\Annotate\Post::class, + \Kiri\Router\Annotate\Put::class, + \Kiri\Router\Annotate\Delete::class, + \Kiri\Router\Annotate\Route::class, + ])) { + $instance = $attr->newInstance(); + $routePath = $instance->path ?? ''; + if (str_contains($routePath, 'header')) { + $found[] = "{$class}::{$method->getName()} -> {$attr->getName()} path={$routePath} version={$instance->version}"; + } + } + } + } + } catch (\Throwable) {} + } + } + if (!empty($found)) { + \Kiri::getLogger()->info("Annotation route search '{$searchPath}': " . implode(' | ', $found)); + } else { + \Kiri::getLogger()->warning("Annotation route search '{$searchPath}': NO annotation found in any of {$classCount} classes"); + } + } }