Class: Rack::AvvoIgnite

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/avvo_ignite.rb

Instance Method Summary collapse

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, options = {})
  @app = app
  @ignite_host = options[:host] || "ia.avvo.com"
  @tracker_code = options[: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>', message + '</body>')
    headers['Content-Length'] = Rack::Utils.bytesize(response.body.to_s).to_s
  end

  [status, headers, response]
end