diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-12-24 10:30:21 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-02-19 16:45:59 +0100 |
commit | 16e3d006e9e9386001881053f610657525feb188 (patch) | |
tree | 514ddc5f97d12d5d0582f081cbdfc8a318aa9d17 /index.php | |
parent | 65e56cbe49a7eb2a0cb09dda85daab3b921472ee (diff) | |
download | Shaarli-16e3d006e9e9386001881053f610657525feb188.tar.gz Shaarli-16e3d006e9e9386001881053f610657525feb188.tar.zst Shaarli-16e3d006e9e9386001881053f610657525feb188.zip |
REST API: implements getLink by ID service
See http://shaarli.github.io/api-documentation/#links-link-get
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -2232,12 +2232,13 @@ $app = new \Slim\App($container); | |||
2232 | $app->group('/api/v1', function() { | 2232 | $app->group('/api/v1', function() { |
2233 | $this->get('/info', '\Shaarli\Api\Controllers\Info:getInfo'); | 2233 | $this->get('/info', '\Shaarli\Api\Controllers\Info:getInfo'); |
2234 | $this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks'); | 2234 | $this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks'); |
2235 | $this->get('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:getLink'); | ||
2235 | })->add('\Shaarli\Api\ApiMiddleware'); | 2236 | })->add('\Shaarli\Api\ApiMiddleware'); |
2236 | 2237 | ||
2237 | $response = $app->run(true); | 2238 | $response = $app->run(true); |
2238 | // Hack to make Slim and Shaarli router work together: | 2239 | // Hack to make Slim and Shaarli router work together: |
2239 | // If a Slim route isn't found, we call renderPage(). | 2240 | // If a Slim route isn't found and NOT API call, we call renderPage(). |
2240 | if ($response->getStatusCode() == 404) { | 2241 | if ($response->getStatusCode() == 404 && strpos($_SERVER['REQUEST_URI'], '/api/v1') === false) { |
2241 | // We use UTF-8 for proper international characters handling. | 2242 | // We use UTF-8 for proper international characters handling. |
2242 | header('Content-Type: text/html; charset=utf-8'); | 2243 | header('Content-Type: text/html; charset=utf-8'); |
2243 | renderPage($conf, $pluginManager, $linkDb); | 2244 | renderPage($conf, $pluginManager, $linkDb); |