public function generateRoutesData(RouteParser $routeParser, DataGenerator $dataGenerator)
    {
        $routes = [];

        foreach ($this->routes as $name => $route) {
            if ($route['group']) {
                if (!isset($this->groups[$route['group']])) {
                    throw new \LogicException(sprintf(
                        'The route group "%s" is not found',
                        $route['group']
                    ));
                }
                $pattern = $this->groups[$route['group']][0] . $route['pattern'];
                $middlewares = array_merge($this->groups[$route['group']][1], $route['middlewares']);
            } else {
                $pattern = $route['pattern'];
                $middlewares = $route['middlewares'];
            }

            $routeDatas = $routeParser->parse($pattern);
            $this->addToDataGenerator($route['methods'], $routeDatas, $name, $dataGenerator);

            $routes[$name] = [
                'datas' => $routeDatas,
                'methods' => $route['methods'],
                'pattern' => $pattern,
                'middlewares' => $middlewares,
                'handler' => $route['handler'],
                'group' => $route['group']
            ];
        }

        return ['routes' => $routes, 'dispatch_data' => $dataGenerator->getData()];
    }