diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-20 15:53:05 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-20 15:53:23 +0200 |
commit | 15b7b9ec4117bf19168ea0f923ea11e926edcc5c (patch) | |
tree | 76c9092445c3619d343c810541e49a84522624b1 /app | |
parent | 57ff963129a37b27f3944f0ec2d0212da9b23e84 (diff) | |
download | gitlab-ce-15b7b9ec4117bf19168ea0f923ea11e926edcc5c.tar.gz |
Add rescue_from(ActionController::UnknownFormat) in Application Controller
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects/deployments_controller.rb | 16 | ||||
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/prometheus_controller.rb | 4 |
4 files changed, 20 insertions, 12 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 91694ebcd1d..824ce845706 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -40,6 +40,10 @@ class ApplicationController < ActionController::Base render_404 end + rescue_from(ActionController::UnknownFormat) do + render_404 + end + rescue_from Gitlab::Access::AccessDeniedError do |exception| render_403 end diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb index acf5573935a..47c312ffddf 100644 --- a/app/controllers/projects/deployments_controller.rb +++ b/app/controllers/projects/deployments_controller.rb @@ -25,12 +25,16 @@ class Projects::DeploymentsController < Projects::ApplicationController def additional_metrics return render_404 unless deployment.has_additional_metrics? - metrics = deployment.additional_metrics - - if metrics.any? - render json: metrics - else - head :no_content + respond_to do |format| + format.json do + metrics = deployment.additional_metrics + + if metrics.any? + render json: metrics + else + head :no_content + end + end end end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 557049c0b22..3869d4b2d56 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -132,9 +132,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController end def additional_metrics - additional_metrics = environment.additional_metrics || {} + respond_to do |format| + format.json do + additional_metrics = environment.additional_metrics || {} - render json: additional_metrics, status: additional_metrics.any? ? :ok : :no_content + render json: additional_metrics, status: additional_metrics.any? ? :ok : :no_content + end + end end private diff --git a/app/controllers/projects/prometheus_controller.rb b/app/controllers/projects/prometheus_controller.rb index 7b828981dd8..507468d7102 100644 --- a/app/controllers/projects/prometheus_controller.rb +++ b/app/controllers/projects/prometheus_controller.rb @@ -18,10 +18,6 @@ class Projects::PrometheusController < Projects::ApplicationController private - rescue_from(ActionController::UnknownFormat) do - render_404 - end - def require_prometheus_metrics! render_404 unless project.prometheus_service.present? end |