} catch (Exception $exception) { header("HTTP/1.0 403 Forbidden"); $GLOBALS['Response']->sendJSON(array('error' => $exception->getMessage())); die; } preg_match('/^\\/api\\/v(\\d+)\\//', $_SERVER['REQUEST_URI'], $matches); $version = floor(file_get_contents(__DIR__ . '/VERSION')); if ($matches && isset($matches[1]) && $matches[1] == 2) { $version = 2; } // Do not put .json at the end of the resource Resources::$useFormatAsExtension = false; //Do not hide the API Resources::$hideProtected = false; // Use /api/v1/projects uri Defaults::$useUrlBasedVersioning = true; if (ForgeConfig::get('DEBUG_MODE')) { $restler = new Restler(false, true); } else { $restler = new Restler(); } $restler->setAPIVersion($version); $restler->setSupportedFormats('JsonFormat', 'XmlFormat'); $core_resources_injector = new Tuleap\REST\ResourcesInjector(); $core_resources_injector->populate($restler); switch ($version) { case 2: $event = Event::REST_RESOURCES_V2; break; default: $event = Event::REST_RESOURCES;