diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-07-30 21:03:41 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-07-30 21:19:02 +0200 |
commit | 7a24f0cd8d28e60360127da19e40bff4b2e04168 (patch) | |
tree | 43ebd6c9e00679536c565d69e561f631d352ad34 /lib/api.php | |
parent | 180bd69dbb21dc6e53533a7d93972445b2ff922e (diff) | |
download | nextcloud-server-7a24f0cd8d28e60360127da19e40bff4b2e04168.tar.gz nextcloud-server-7a24f0cd8d28e60360127da19e40bff4b2e04168.zip |
Make calling ocs/v1.php/config work
Diffstat (limited to 'lib/api.php')
-rw-r--r-- | lib/api.php | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/api.php b/lib/api.php index fd2c621f389..515bab6714e 100644 --- a/lib/api.php +++ b/lib/api.php @@ -43,7 +43,8 @@ class OC_API { $name = str_replace(array('/', '{', '}'), '_', $name); if(!isset(self::$actions[$name])){ OC::$router->create($name, $url.'.{_format}') - ->defaults(array('_format'=>'xml')) + ->defaults(array('_format' => 'xml')) + ->requirements(array('_format' => 'xml|json')) ->action('OC_API', 'call'); self::$actions[$name] = array(); } @@ -55,7 +56,7 @@ class OC_API { * @param array $parameters */ public static function call($parameters){ - $name = $parameters['_name']; + $name = $parameters['_route']; // Loop through registered actions foreach(self::$actions[$name] as $action){ $app = $action['app']; @@ -107,8 +108,14 @@ class OC_API { * @param int|array $response the response * @param string $format the format xml|json */ - private function respond($response, $format='json'){ - // TODO respond in the correct format + private static function respond($response, $format='json'){ + if ($format == 'json') { + echo json_encode($response); + } else if ($format == 'xml') { + // TODO array to xml + } else { + var_dump($format, $response); + } } -}
\ No newline at end of file +} |