diff --git a/bin/paramcli b/bin/paramcli index 19cc31a..1d97f9f 100755 --- a/bin/paramcli +++ b/bin/paramcli @@ -87,7 +87,7 @@ function http_get(string $url, array $headers) { function http_post(string $url, array $headers, ?string $body = null) { global $opts,$http; - return $http->post("http://{$opts->server}/{$url}", $headers, $body); + return $http->post("http://{$opts->server}/{$url}", $headers, $body??''); } function action_get(object $opts) { @@ -140,7 +140,7 @@ function action_purge(object $opts) { if (!$collection) { exit_error("Missing collection. Expected: purge {collection}"); } - http_post($collection."/delete", [], null)->then( + http_post($collection."/purge", [], null)->then( function ($response) { echo $response->getBody()->getContents(); }, diff --git a/src/Daemon.php b/src/Daemon.php index 4a95814..be3ea7e 100644 --- a/src/Daemon.php +++ b/src/Daemon.php @@ -113,7 +113,6 @@ class Daemon return Response::json([ 'error' => "Invalid request method" ]); } try { - $ids = json_decode($request->getBody()->getContents(), true); $this->opCollectionPurge($collectionName); } catch (\Exception $e) { return Response::json([ 'error' => "No such collection" ])->withStatus(404); @@ -155,7 +154,7 @@ class Daemon try { $collection = $this->db->getCollection($collectionName); foreach ($ids as $id) { - if (is_int($id)) { + if (intval($id) > 0) { $collection->deleteValue(intval($id)); } else { $collection->deleteKey($id);