Class: RackPhantom::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



15
16
17
# File 'lib/rack_phantom.rb', line 15

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/rack_phantom.rb', line 19

def call(env)
  status, headers, response = @app.call(env)

  return [status, headers, response] unless render?(headers, env)

  html = Phantomjs.run('js/render.js', %['#{response}'])
  [status, headers, html]
end