Class: VitalsMonitor::VitalsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- VitalsMonitor::VitalsController
- Defined in:
- app/controllers/vitals_monitor/vitals_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/vitals_monitor/vitals_controller.rb', line 7 def index @results = check_all_components @overall_status = overall_status(@results) status_code = @overall_status == :unhealthy ? 503 : 200 respond_to do |format| format.html { render status: status_code } format.json { render json: format_json_response(@results, @overall_status), status: status_code } end end |
#show ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/vitals_monitor/vitals_controller.rb', line 18 def show component = params[:component].to_sym unless VitalsMonitor.config.enabled?(component) respond_to do |format| format.html { render status: 404 } format.json { render json: { error: "Component #{component} is not enabled" }, status: 404 } end return end result = check_component(component) @result = result @component = component @status = result[:status] status_code = result[:status] == :unhealthy ? 503 : 200 respond_to do |format| format.html { render status: status_code } format.json { render json: format_single_json_response(component, result), status: status_code } end end |