class HealthCheck::HealthCheckController
Public Instance Methods
index()
click to toggle source
# File lib/health_check/health_check_controller.rb, line 9 def index checks = params[:checks] || 'standard' begin errors = HealthCheck::Utils.process_checks(checks) rescue Exception => e errors = e.message end if errors.blank? obj = { :healthy => true, :message => HealthCheck.success } respond_to do |format| format.html { render :text => HealthCheck.success, :content_type => 'text/plain' } format.json { render :xml => obj.to_json } format.xml { render :xml => obj.to_xml } format.any { render :text => HealthCheck.success, :content_type => 'text/plain' } end else msg = "health_check failed: #{errors}" obj = { :healthy => false, :message => msg } respond_to do |format| format.html { render :text => msg, :status => HealthCheck.http_status_for_error_text, :content_type => 'text/plain' } format.json { render :xml => obj.to_json, :status => HealthCheck.http_status_for_error_object} format.xml { render :xml => obj.to_xml, :status => HealthCheck.http_status_for_error_object } format.any { render :text => msg, :status => HealthCheck.http_status_for_error_text, :content_type => 'text/plain' } end # Log a single line as some uptime checkers only record that it failed, not the text returned if logger silence_level, logger.level = logger.level, @old_logger_level if @old_logger_level logger.info msg logger.level = silence_level if @old_logger_level end end end
Protected Instance Methods
process_with_silent_log(method_name, *args)
click to toggle source
# File lib/health_check/health_check_controller.rb, line 54 def process_with_silent_log(method_name, *args) if logger @old_logger_level = logger.level if Rails.version >= '3.2' silence do process_without_silent_log(method_name, *args) end else logger.silence do process_without_silent_log(method_name, *args) end end else process_without_silent_log(method_name, *args) end end
protect_against_forgery?()
click to toggle source
turn cookies for CSRF off
# File lib/health_check/health_check_controller.rb, line 46 def protect_against_forgery? false end