aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/api
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-05-06 17:32:16 +0200
committerArthurHoaro <arthur@hoa.ro>2017-05-07 15:58:49 +0200
commit0843848c1d18e92504c43d181063a2012f8fd5b9 (patch)
treefaf798ea7d1e4a41edce202cebd0cd7d45e22300 /application/api
parentcf9181dddf8b6113b1b017e4bcb21fac0a0b1c83 (diff)
downloadShaarli-0843848c1d18e92504c43d181063a2012f8fd5b9.tar.gz
Shaarli-0843848c1d18e92504c43d181063a2012f8fd5b9.tar.zst
Shaarli-0843848c1d18e92504c43d181063a2012f8fd5b9.zip
API: add DELETE endpoint
Based on #840 See http://shaarli.github.io/api-documentation/\#links-link-delete
Diffstat (limited to 'application/api')
-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}