Class: StandardHealth::DiagnosticsController

Inherits:
ApplicationController 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 via ‘parent_controller` — typically a basic-auth `before_action` on `ApplicationController`.

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”.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/standard_health/diagnostics_controller.rb', line 13

def env
  spec = StandardHealth.config.env_spec
  mode = ENV["APP_ENVIRONMENT"].to_s

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

  render json: {
    mode: mode,
    audit: audit,
    generated_at: Time.now.utc.iso8601
  }
end