#rails, #dev

Rails 7 introduce default healthcheck controller

DHH introduce default HealthCheckController for Rails 7 ♦

Which is just this piece of code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class Rails::HealthController < ActionController::Base # :nodoc:
  rescue_from(Exception) { render_down }

  def show
    render_up
  end

  private
    def render_up
      render html: html_status(color: "green")
    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

PR https://github.com/rails/rails/pull/46936


Comment with Disqus

Comment with an Email

No comments here yet Write here gently

Comment with Talkyard

Comments powered by Talkyard.