Class: Headhunter::Rack::CapturingMiddleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app, headhunter) ⇒ CapturingMiddleware

Returns a new instance of CapturingMiddleware.



4
5
6
7
# File 'lib/headhunter/rack/capturing_middleware.rb', line 4

def initialize(app, headhunter)
  @app = app
  @hh  = headhunter
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
# File 'lib/headhunter/rack/capturing_middleware.rb', line 9

def call(env)
  response = @app.call(env)
  process(response)
  response
end

#extract_html_from(response) ⇒ Object



23
24
25
# File 'lib/headhunter/rack/capturing_middleware.rb', line 23

def extract_html_from(response)
  response[0]
end

#process(rack_response) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/headhunter/rack/capturing_middleware.rb', line 15

def process(rack_response)
  status, headers, response = rack_response

  if html = extract_html_from(response)
    @hh.process('unknown', html)
  end
end