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.



6
7
8
# File 'lib/rack/record.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rack/record.rb', line 10

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