router = $router; } public function json(Request $request, array $params) { $routes = []; foreach ($this->router->getRoutes() as $method => $paths) { foreach ($paths as $path => $route) { $routes[] = [ 'method' => $method, 'path' => $path, 'name' => $route['name'] ?? null, 'middleware_count' => isset($route['middleware']) ? count($route['middleware']) : 0, ]; } } return (new Response())->withJson($routes, 200, JSON_PRETTY_PRINT); } public function html(Request $request, array $params) { $routes = []; foreach ($this->router->getRoutes() as $method => $paths) { foreach ($paths as $path => $route) { $routes[] = [ 'method' => $method, 'path' => $path, 'name' => $route['name'] ?? '', 'middleware_count' => isset($route['middleware']) ? count($route['middleware']) : 0, ]; } } $html = '

Routen-Übersicht

'; foreach ($routes as $route) { $link = '' . htmlspecialchars($route['path']) . ''; $html .= ''; } $html .= '
MethodPathNameMiddleware
' . htmlspecialchars($route['method']) . '' . $link . '' . htmlspecialchars($route['name']) . '' . $route['middleware_count'] . '
'; return (new Response())->withHtml($html); } }