Add core routes and include them in OC_API::call()

This commit is contained in:
Tom Needham 2012-07-30 10:56:21 +00:00
parent cbc0f0c1c5
commit e33174f115
2 changed files with 30 additions and 3 deletions

25
core/routes.php Normal file
View File

@ -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'));
?>

View File

@ -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();