summaryrefslogtreecommitdiff
path: root/app/controllers/api/keys_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/api/keys_controller.rb')
-rw-r--r--app/controllers/api/keys_controller.rb12
1 files changed, 12 insertions, 0 deletions
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