public function finalize()
    {
        if (!$this->finalized) {
            foreach ($this->getRoutes() as $route) {
                $route->finalize();
                $this->addRoute($route->getMethods(), $route->getPattern(), [$route, 'run']);
            }
            $this->finalized = true;
        }
    }