diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-10-05 09:42:36 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-10-05 09:42:36 +0200 |
commit | f3a211c03c3dd017e263ac5226a52eb62562d198 (patch) | |
tree | 4161ed0ab3b5fe695d08dc0d51df0a0ea02fe313 /lib/router.php | |
parent | 167e9c1cc025ce920e48032ff5331fcb4f84de3d (diff) | |
download | nextcloud-server-f3a211c03c3dd017e263ac5226a52eb62562d198.tar.gz nextcloud-server-f3a211c03c3dd017e263ac5226a52eb62562d198.zip |
Implement routing on javascript side
Diffstat (limited to 'lib/router.php')
-rw-r--r-- | lib/router.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/router.php b/lib/router.php index da491e217fc..04a3d410060 100644 --- a/lib/router.php +++ b/lib/router.php @@ -94,4 +94,22 @@ class OC_Router { { return $this->getGenerator()->generate($name, $parameters, $absolute); } + + public static function JSRoutes() + { + // TODO: http caching + $routes = array(); + $router = OC::getRouter(); + $root = $router->getCollection('root'); + foreach($root->all() as $name => $route) { + $compiled_route = $route->compile(); + $defaults = $route->getDefaults(); + unset($defaults['action']); + $routes[$name] = array( + 'tokens' => $compiled_route->getTokens(), + 'defaults' => $defaults, + ); + } + OCP\JSON::success ( array( 'data' => $routes ) ); + } } |