aboutsummaryrefslogtreecommitdiffstats
path: root/lib/router.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/router.php')
-rw-r--r--lib/router.php18
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 ) );
+ }
}