Class: Rack::AvvoIgnite
- Inherits:
-
Object
- Object
- Rack::AvvoIgnite
- Defined in:
- lib/rack/avvo_ignite.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ AvvoIgnite
constructor
A new instance of AvvoIgnite.
Constructor Details
#initialize(app, options = {}) ⇒ AvvoIgnite
Returns a new instance of AvvoIgnite.
4 5 6 7 8 |
# File 'lib/rack/avvo_ignite.rb', line 4 def initialize(app, = {}) @app = app @ignite_host = [:host] || "ia.avvo.com" @tracker_code = [:code] end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rack/avvo_ignite.rb', line 10 def call(env) status, headers, response = @app.call(env) if headers['Content-Type'].to_s.include?('text/html') # Only update HTML bodies response.body = response.body.gsub('</body>', + '</body>') headers['Content-Length'] = Rack::Utils.bytesize(response.body.to_s).to_s end [status, headers, response] end |