From 54653f75cf44890310a06c3a8a6be59625629d2a Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 19 Jan 2018 14:11:24 +0100 Subject: API: implement deleting keys through new keys api --- app/controllers/api/keys_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/controllers/api') diff --git a/app/controllers/api/keys_controller.rb b/app/controllers/api/keys_controller.rb index d4cb759..7eb76ee 100644 --- a/app/controllers/api/keys_controller.rb +++ b/app/controllers/api/keys_controller.rb @@ -25,10 +25,22 @@ class Api::KeysController < ApiController def update keyring.update type, rev: rev, value: value head :no_content + rescue Keyring::NotFound => e + render status: 404, json: {error: e.message} rescue Keyring::Error, ActionController::ParameterMissing => e render status: 422, json: {error: e.message} end + def destroy + keyring.delete type, rev: rev + head :no_content + rescue Keyring::NotFound => e + render status: 404, json: {error: e.message} + rescue Keyring::Error, ActionController::ParameterMissing => e + render status: 422, json: {error: e.message} + end + + protected def require_enabled -- cgit v1.2.3