Class: Sidekiq::Kicks::Web::ScriptInjector

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/kicks/web.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ScriptInjector

Returns a new instance of ScriptInjector.



12
13
14
# File 'lib/sidekiq/kicks/web.rb', line 12

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/sidekiq/kicks/web.rb', line 16

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

  if html_response?(headers) && inject_path?(env)
    body = inject_script(body, env)
    headers.delete("Content-Length")
  end

  [status, headers, body]
end