Class: Garelic::Middleware
- Inherits:
-
Object
- Object
- Garelic::Middleware
- Defined in:
- lib/garelic/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
2 3 4 5 |
# File 'lib/garelic/middleware.rb', line 2 def initialize(app) @app = app Garelic::Metrics.reset! end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/garelic/middleware.rb', line 7 def call(env) status, headers, response = @app.call(env) if headers["Content-Type"] =~ /text\/html|application\/xhtml\+xml/ body = response.body.gsub(Garelic::Timing, Garelic.report_user_timing_from_metrics(Garelic::Metrics)) response = [body] end Garelic::Metrics.reset! [status, headers, response] end |