public function with($namespace, $routes)
    {
        $previous = $this->route_factory->getNamespace();

        $this->route_factory->appendNamespace($namespace);

        if (is_callable($routes)) {
            if (is_string($routes)) {
                $routes($this);
            } else {
                call_user_func($routes, $this);
            }
        } else {
            require $routes;
        }

        $this->route_factory->setNamespace($previous);
    }
public function with($namespace, $routes)
    {
        $previous = $this->route_factory->getNamespace();

        $this->route_factory->appendNamespace($namespace);

        if (is_callable($routes)) {
            if (is_string($routes)) {
                $routes($this);
            } else {
                call_user_func($routes, $this);
            }
        } else {
            require $routes;
        }

        $this->route_factory->setNamespace($previous);
    }
public function with ( $ namespace , $ routes ) { $ previous = $ this -> route_factory -> getNamespace ( ) ; $ this -> route_factory -> appendNamespace ( $ namespace ) ; if ( is_callable ( $ routes ) ) { if ( is_string ( $ routes ) ) { $ routes ( $ this ) ; } else { call_user_func ( $ routes , $ this ) ; } } else { require $ routes ; } $ this -> route_factory -> setNamespace ( $ previous ) ; }
Collect a set of routes under a common namespace

The routes may be passed in as either a callable (which holds the route definitions),
or as a string of a filename, of which to "include" under the Klein router scope

<code>
$router = new Klein();

$router->with('/users', function($router) {
$router->respond( '/', function() {
// do something interesting
});
$router->respond( '/[i:id]', function() {
// do something different
});
});

$router->with('/cars', __DIR__ . '/routes/cars.php');
</code>

@param string $namespace         The namespace under which to collect the routes
@param callable|string $routes   The defined routes callable or filename to collect under the namespace
@return void
Collect a set of routes under a common namespace