public function merge(self $router) {
        if ($this->running) {
            throw new \Error("Cannot merge routers after the server has started");
        }

        foreach ($router->routes as $route) {
            $route[1] = \ltrim($router->prefix, "/") . $route[1];
            $route[2] = Middleware\stack($route[2], ...$router->middlewares);
            $this->routes[] = $route;
        }

        $this->observers->addAll($router->observers);
    }
public function merge(self $router) {
        if ($this->running) {
            throw new \Error("Cannot merge routers after the server has started");
        }

        foreach ($router->routes as $route) {
            $route[1] = \ltrim($router->prefix, "/") . $route[1];
            $route[2] = Middleware\stack($route[2], ...$router->middlewares);
            $this->routes[] = $route;
        }

        $this->observers->addAll($router->observers);
    }
public function merge ( self $ router ) { if ( $ this -> running ) { throw new \ Error ( "Cannot merge routers after the server has started" ) ; } foreach ( $ router -> routes as $ route ) { $ route [ 1 ] = \ ltrim ( $ router -> prefix , "/" ) . $ route [ 1 ] ; $ route [ 2 ] = Middleware \ stack ( $ route [ 2 ] , ... $ router -> middlewares ) ; $ this -> routes [ ] = $ route ; } $ this -> observers -> addAll ( $ router -> observers ) ; }
Merge another router's routes into this router.

Doing so might improve performance for request dispatching.

@param self $router Router to merge.
Merge another router s routes into this router .