From e33174f115d7459afb15131f0bc4a6386a673608 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 30 Jul 2012 10:56:21 +0000 Subject: [PATCH] Add core routes and include them in OC_API::call() --- core/routes.php | 25 +++++++++++++++++++++++++ lib/api.php | 8 +++++--- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 core/routes.php diff --git a/core/routes.php b/core/routes.php new file mode 100644 index 0000000000..4c5004dcf5 --- /dev/null +++ b/core/routes.php @@ -0,0 +1,25 @@ + + * This file is licensed under the Affero General Public License version 3 or later. + * See the COPYING-README file. + */ + +// Config +OC_API::register('get', '/config.{format}', array('OC_API_Config', 'apiConfig')); +// Person +OC_API::register('post', '/person/check.{format}', array('OC_API_Person', 'check')); +// Activity +OC_API::register('get', '/activity.{format}', array('OC_API_Activity', 'activityGet')); +OC_API::register('post', '/activity.{format}', array('OC_API_Activity', 'activityPut')); +// Privatedata +OC_API::register('get', '/privatedata/getattribute/{app}/{key}.{format}', array('OC_API_Privatedata', 'privatedataGet')); +OC_API::register('post', '/privatedata/setattribute/{app}/{key}.{format}', array('OC_API_Privatedata', 'privatedataPut')); +OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}.{format}', array('OC_API_Privatedata', 'privatedataDelete')); +// Cloud +OC_API::register('get', '/cloud/system/webapps.{format}', array('OC_API_Cloud', 'systemwebapps')); +OC_API::register('get', '/cloud/user/{user}.{format}', array('OC_API_Cloud', 'getQuota')); +OC_API::register('post', '/cloud/user/{user}.{format}', array('OC_API_Cloud', 'setQuota')); +OC_API::register('get', '/cloud/user/{user}/publickey.{format}', array('OC_API_Cloud', 'getPublicKey')); +OC_API::register('get', '/cloud/user/{user}/privatekey.{format}', array('OC_API_Cloud', 'getPrivateKey')); +?> \ No newline at end of file diff --git a/lib/api.php b/lib/api.php index cf40167b07..b1176a0707 100644 --- a/lib/api.php +++ b/lib/api.php @@ -29,7 +29,7 @@ class OC_API { /** * api actions */ - protected $actions = array(); + protected static $actions = array(); /** * registers an api call @@ -37,7 +37,7 @@ class OC_API { * @param string $url the url to match * @param callable $action the function to run */ - public function register($method, $url, $action){ + public static function register($method, $url, $action){ $name = strtolower($method).$url; if(!isset(self::$actions[$name])){ OC_Router::create($name, $url) @@ -51,7 +51,7 @@ class OC_API { * handles an api call * @param array $parameters */ - public function call($parameters){ + public static function call($parameters){ // Get the routes // TODO cache @@ -61,6 +61,8 @@ class OC_API { require_once($file); } } + // include core routes + require_once(OC::$SERVERROOT.'core/routes.php'); $name = $parameters['_name']; $response = array();