Class: RailsHealthChecks::HealthController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_health_checks/health_controller.rb

Instance Method Summary collapse

Methods included from Authentication

#authenticate!

Instance Method Details

#groupObject



19
20
21
22
23
24
25
26
# File 'app/controllers/rails_health_checks/health_controller.rb', line 19

def group
  group_name = params[:group].to_sym
  check_names = RailsHealthChecks.configuration.groups[group_name]
  return render json: { error: "Group '#{group_name}' not found" }, status: :not_found unless check_names

  builder = ResponseBuilder.new(run_checks(check_names))
  render json: builder.to_json, status: builder.http_status
end

#liveObject



10
11
12
13
14
15
16
17
# File 'app/controllers/rails_health_checks/health_controller.rb', line 10

def live
  builder = ResponseBuilder.new(run_checks(RailsHealthChecks.configuration.checks))
  if builder.overall_status == "ok"
    render plain: "OK", status: :ok
  else
    render plain: "Service Unavailable", status: :service_unavailable
  end
end

#showObject



5
6
7
8
# File 'app/controllers/rails_health_checks/health_controller.rb', line 5

def show
  builder = ResponseBuilder.new(run_checks(RailsHealthChecks.configuration.checks))
  render json: builder.to_json, status: builder.http_status
end