Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use explicit module for Rails::HealthController #47728

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 17 additions & 15 deletions railties/lib/rails/health_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@
# where your application is being restarted due to a third-party service going
# bad. Ideally, you should design your application to handle those outages
# gracefully.
class Rails::HealthController < ActionController::Base
rescue_from(Exception) { render_down }
module Rails
class HealthController < ActionController::Base
rescue_from(Exception) { render_down }

def show
render_up
end

private
def render_up
render html: html_status(color: "green")
def show
render_up
end

def render_down
render html: html_status(color: "red"), status: 500
end
private
def render_up
render html: html_status(color: "green")
end

def html_status(color:)
%(<html><body style="background-color: #{color}"></body></html>).html_safe
end
def render_down
render html: html_status(color: "red"), status: 500
end

def html_status(color:)
%(<html><body style="background-color: #{color}"></body></html>).html_safe
end
end
end