Class: Gesund::Output::Rack
- Inherits:
-
Object
- Object
- Gesund::Output::Rack
- Defined in:
- lib/gesund/output/rack.rb
Instance Attribute Summary collapse
-
#checks ⇒ Object
Returns the value of attribute checks.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#checks ⇒ Object
Returns the value of attribute checks.
14 15 16 |
# File 'lib/gesund/output/rack.rb', line 14 def checks @checks end |
Class Method Details
.start(checks, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/gesund/output/rack.rb', line 5 def self.start(checks, ={}) app = self.new app.checks = checks # http://rubydoc.info/github/rack/rack/master/Rack/Server#initialize-instance_method [:Port] = .delete 'port' [:Host] = .delete 'host' ::Rack::Server.start({ :app => app }.merge()) end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 |