Class: Katalyst::Healthcheck::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/katalyst/healthcheck/route.rb

Overview

Represents a status and a message that can be used in a rails route

Class Method Summary collapse

Class Method Details

.from_tasks(detail: false) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/katalyst/healthcheck/route.rb', line 12

def from_tasks(detail: false)
  Proc.new do |_env|
    tasks = Task.all
    status = tasks.all?(&:ok?) ? 200 : 500
    message = status == 200 ? "OK" : "FAIL"
    message = Task.summary if detail
    [status, { "Content-Type" => "text/plain" }, [message]]
  end
end

.static(status, message) ⇒ Object



8
9
10
# File 'lib/katalyst/healthcheck/route.rb', line 8

def static(status, message)
  Proc.new { |_env| [status, { "Content-Type" => "text/plain" }, [message]] }
end