diff --git a/core/routes.php b/core/routes.php new file mode 100644 index 0000000000000000000000000000000000000000..4c5004dcf5a98156ae16008184b9a8183ab3ca4d --- /dev/null +++ b/core/routes.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright (c) 2012, Tom Needham <tom@owncloud.com> + * 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 cf40167b07a0bcd3fc8a552a7ac17cbf117efdec..b1176a07077968ff8953d20cef8760180f5b79d4 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();