diff options
-rw-r--r-- | lib/ocs.php | 7 | ||||
-rw-r--r-- | lib/route.php | 4 | ||||
-rw-r--r-- | lib/router.php | 8 |
3 files changed, 14 insertions, 5 deletions
diff --git a/lib/ocs.php b/lib/ocs.php index d7a7951fab5..1df08df9fa1 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -23,6 +23,9 @@ * */ +use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Symfony\Component\Routing\Exception\MethodNotAllowedException; + /** * Class to handle open collaboration services API requests * @@ -93,7 +96,7 @@ class OC_OCS { $format = self::readData($method, 'format', 'text', ''); $router = new OC_Router(); - $router->useCollection('ocs'); + $router->useCollection('root'); // CONFIG $router->create('config', '/config.{format}') ->defaults(array('format' => $format)) @@ -247,6 +250,8 @@ class OC_OCS { $txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n"; $txt.=OC_OCS::getdebugoutput(); echo(OC_OCS::generatexml($format,'failed',999,$txt)); + } catch (MethodNotAllowedException $e) { + OC_Response::setStatus(405); } exit(); } diff --git a/lib/route.php b/lib/route.php index df3a18e844f..772446e5615 100644 --- a/lib/route.php +++ b/lib/route.php @@ -50,7 +50,9 @@ class OC_Route extends Route { if (isset($requirements['_method'])) { $method = $requirements['_method']; } - $this->method($method); + if ($method) { + $this->method($method); + } return $this; } diff --git a/lib/router.php b/lib/router.php index 3ba2125465a..dbcaff4026e 100644 --- a/lib/router.php +++ b/lib/router.php @@ -10,19 +10,21 @@ use Symfony\Component\Routing\Matcher\UrlMatcher; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RouteCollection; //use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; class OC_Router { protected $collections = array(); protected $collection = null; protected $root = null; + public function __construct() { + // TODO cache + $this->root = $this->getCollection('root'); + } + /** * loads the api routes */ public function loadRoutes() { - // TODO cache - $this->root = $this->getCollection('root'); foreach(OC_APP::getEnabledApps() as $app){ $file = OC_App::getAppPath($app).'/appinfo/routes.php'; if(file_exists($file)){ |