I tried build restful api using phalcon route annonation GET, PUT, POST annotation is working but DELETE method is not. It just said not found method.
/**
* @Post("/")
*/
public function addAction()
{
$level = $this->request->getPost("level");
$ignore_limit = $this->request->getPost("ignore_limit");
$api = new ApiKeysModel();
$api->setKey($this->generateApiKey());
$api->setIgnoreLimit((isset($ignore_limit) ? $ignore_limit : 0));
$api->setLevel((isset($level) ? $level : 1));
if ($api->save()) {
return $this->apiResponse->withItem($api, new KeyTransformer());
} else {
return $this->apiResponse->errorInternalError();
}
}
/**
* @Delete("/")
*/
public function deleteAction()
{
$key = "1";
$api = ApiKeysModel::findFirst("key = '{$key}'");
if (!$api) {
return $this->apiResponse->errorInternalError();
}
$api->delete();
$this->apiResponse->withArray(["deleted" => true]);
}