class MiniCheck::RackApp
Constants
- CONTENT_TYPE_HEADER
- JSON_MIME_TYPE
- PATH_INFO
- REQUEST_METHOD
Attributes
checks[RW]
host_app[RW]
path[RW]
Public Class Methods
new(args = {})
click to toggle source
# File lib/mini_check/rack_app.rb, line 11 def initialize args = {} set_attributes args end
Public Instance Methods
call(env)
click to toggle source
# File lib/mini_check/rack_app.rb, line 19 def call env case "#{env[REQUEST_METHOD]} #{env[PATH_INFO]}" when "GET #{path}" checks.run [status, default_headers, [body]] else host_app.call(env) end end
new(app)
click to toggle source
# File lib/mini_check/rack_app.rb, line 33 def new(app) dup.tap do |copy| copy.host_app = app end end
register(name, &block)
click to toggle source
# File lib/mini_check/rack_app.rb, line 29 def register name, &block checks.register name, &block end
Private Instance Methods
body()
click to toggle source
# File lib/mini_check/rack_app.rb, line 51 def body checks.to_hash.to_json end
default_headers()
click to toggle source
# File lib/mini_check/rack_app.rb, line 41 def default_headers { CONTENT_TYPE_HEADER => JSON_MIME_TYPE } end
set_attributes(args = {})
click to toggle source
# File lib/mini_check/rack_app.rb, line 45 def set_attributes args = {} args.each do |k,v| send("#{k}=", v) end end
status()
click to toggle source
# File lib/mini_check/rack_app.rb, line 55 def status checks.healthy? ? 200 : 500 end