Class: Rack::Rewritten::Record

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Record

Returns a new instance of Record.



9
10
11
# File 'lib/rack/record.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rack/record.rb', line 13

def call(env)
  req = Rack::Request.new(env.clone)
  status, headers, response = @app.call(env)
  puts "-> Rack::Rewritten::Record"
  puts headers.inspect

  if [200,301,302].include?(status)
    ::Rewritten.add_hit(req.path,status, headers["Content-Type"]) if headers["Content-Type"] =~ /text\/html/
  end

  [status, headers, response]
end