Class: StandardHealth::DiagnosticsController

Inherits:
DiagnosticsApplicationController show all
Defined in:
app/controllers/standard_health/diagnostics_controller.rb

Overview

Diagnostics endpoints. Output here is potentially sensitive (it enumerates which env vars are missing), so host apps are responsible for wrapping these routes with authentication.

Inherits from DiagnosticsApplicationController, which resolves to config.diagnostics_parent_controller || config.parent_controller. This lets host apps put auth on diagnostics only — e.g. an HTTP Basic before_action :auth, only: :env on a dedicated diagnostics parent — without that callback leaking onto HealthController and tripping Rails 7.1's raise_on_missing_callback_actions.

Instance Method Summary collapse

Instance Method Details

#envObject

Audits the configured EnvSpec against the current process ENV and returns the result as JSON. When no EnvSpec is configured the endpoint returns an empty audit rather than a 404 so callers don't have to special-case "feature not enabled".



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/standard_health/diagnostics_controller.rb', line 19

def env
  spec = StandardHealth.config.env_spec
  mode = ENV["APP_ENVIRONMENT"].to_s
  root = defined?(Rails) ? Rails.root : nil

  audit = spec ? spec.audit(ENV.to_h, mode: mode, root: root) : []

  render json: {
    mode: mode,
    status: audit_status(audit),
    audit: audit,
    generated_at: Time.now.utc.iso8601
  }
end