aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/api/controllers/Links.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-05-07 16:02:14 +0200
committerGitHub <noreply@github.com>2017-05-07 16:02:14 +0200
commitb8fcb7d4403a344158ab5d2c8979bdd002e6001d (patch)
tree2ac6304cfdef1322c19bd47ba972e8894d98ab68 /application/api/controllers/Links.php
parent77de24876ff542e3770aa2845e993c58f87e37df (diff)
parent0843848c1d18e92504c43d181063a2012f8fd5b9 (diff)
downloadShaarli-b8fcb7d4403a344158ab5d2c8979bdd002e6001d.tar.gz
Shaarli-b8fcb7d4403a344158ab5d2c8979bdd002e6001d.tar.zst
Shaarli-b8fcb7d4403a344158ab5d2c8979bdd002e6001d.zip
Merge pull request #856 from ArthurHoaro/api/delete-link
API: add DELETE endpoint
Diffstat (limited to 'application/api/controllers/Links.php')
-rw-r--r--application/api/controllers/Links.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/application/api/controllers/Links.php b/application/api/controllers/Links.php
index 1c68b062..a40e974d 100644
--- a/application/api/controllers/Links.php
+++ b/application/api/controllers/Links.php
@@ -188,4 +188,27 @@ class Links extends ApiController
188 $out = ApiUtils::formatLink($responseLink, $index); 188 $out = ApiUtils::formatLink($responseLink, $index);
189 return $response->withJson($out, 200, $this->jsonStyle); 189 return $response->withJson($out, 200, $this->jsonStyle);
190 } 190 }
191
192 /**
193 * Delete an existing link by its ID.
194 *
195 * @param Request $request Slim request.
196 * @param Response $response Slim response.
197 * @param array $args Path parameters. including the ID.
198 *
199 * @return Response response.
200 *
201 * @throws ApiLinkNotFoundException generating a 404 error.
202 */
203 public function deleteLink($request, $response, $args)
204 {
205 if (! isset($this->linkDb[$args['id']])) {
206 throw new ApiLinkNotFoundException();
207 }
208
209 unset($this->linkDb[(int) $args['id']]);
210 $this->linkDb->save($this->conf->get('resource.page_cache'));
211
212 return $response->withStatus(204);
213 }
191} 214}