Class: Rack::Monitor::MonitorApp
- Inherits:
-
Object
- Object
- Rack::Monitor::MonitorApp
- Defined in:
- lib/rack/monitor/monitor_app.rb
Instance Method Summary collapse
- #call(env, options = {}) ⇒ Object
-
#initialize(app, options = {}) ⇒ MonitorApp
constructor
A new instance of MonitorApp.
Constructor Details
#initialize(app, options = {}) ⇒ MonitorApp
Returns a new instance of MonitorApp.
12 13 14 15 16 17 |
# File 'lib/rack/monitor/monitor_app.rb', line 12 def initialize(app, ={}) @app = app @options = {:url=>'/rack_status'}.merge() sensor_class_names = Rack::Monitor.constants.reject { |s| %q(Sensor MonitorApp).include?(s) } @sensors = sensor_class_names.collect { |s| Rack::Monitor.const_get(s).new } end |
Instance Method Details
#call(env, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rack/monitor/monitor_app.rb', line 19 def call(env, ={}) if env["PATH_INFO"] == @options[:url] [200, {'Content-Type' => 'text/plain'}, [monitor_output]] else @sensors.each { |sensor| sensor.before(env) } status, headers, response = @app.call(env) @sensors.each { |sensor| sensor.after(env) } [status, headers, response] end end |