FastRoute icon indicating copy to clipboard operation
FastRoute copied to clipboard

get route list

Open evilk123 opened this issue 4 years ago • 1 comments

Hi How to get all the routes defined?

evilk123 avatar Dec 31 '21 07:12 evilk123

I don't think you can. The routes passed to RouteCollector::addRoute() are immediately parsed and passed to the dataGenerator inside:

    public function addRoute($httpMethod, $route, $handler)
    {
        $route = $this->currentGroupPrefix . $route;
        $routeDatas = $this->routeParser->parse($route);
        foreach ((array) $httpMethod as $method) {
            foreach ($routeDatas as $routeData) {
                $this->dataGenerator->addRoute($method, $routeData, $handler);
            }
        }
    }

Perhaps if you extend RouteCollector and overwrite addRoute() you can collect the passed routes

kktsvetkov avatar Dec 31 '21 08:12 kktsvetkov