]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
REST API: implements getLink by ID service
[github/shaarli/Shaarli.git] / index.php
index d1eee09850e1dac86531be917c7c5c3a3d3e12ec..8eb36d81a766831ca9e189a53f83267feee72eb3 100644 (file)
--- a/index.php
+++ b/index.php
@@ -2232,12 +2232,13 @@ $app = new \Slim\App($container);
 $app->group('/api/v1', function() {
     $this->get('/info', '\Shaarli\Api\Controllers\Info:getInfo');
     $this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks');
+    $this->get('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:getLink');
 })->add('\Shaarli\Api\ApiMiddleware');
 
 $response = $app->run(true);
 // Hack to make Slim and Shaarli router work together:
-// If a Slim route isn't found, we call renderPage().
-if ($response->getStatusCode() == 404) {
+// If a Slim route isn't found and NOT API call, we call renderPage().
+if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) {
     // We use UTF-8 for proper international characters handling.
     header('Content-Type: text/html; charset=utf-8');
     renderPage($conf, $pluginManager, $linkDb);