class Gesund::Output::Rack
Attributes
checks[RW]
Public Class Methods
start(checks, options={})
click to toggle source
# File lib/gesund/output/rack.rb, line 5 def self.start(checks, options={}) app = self.new app.checks = checks # http://rubydoc.info/github/rack/rack/master/Rack/Server#initialize-instance_method options[:Port] = options.delete 'port' options[:Host] = options.delete 'host' ::Rack::Server.start({ :app => app }.merge(options)) end
Public Instance Methods
call(env)
click to toggle source
# File lib/gesund/output/rack.rb, line 16 def call(env) results = Gesund::CheckRunner.run(self.checks) body = [] failflag = false results.each do |check| failflag = true if check.first.to_i != 200 body << "#{check.first}: #{check.last.join}\n" end status = failflag ? 500 : 200 header = { "Content-Type" => "text/plain" } [status, header, body] end