Class: CautionTape::Middleware

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

Overview

Rack middleware that injects the environment chrome into HTML responses, just before .

Constant Summary collapse

BODY_CLOSE =
"</body>"

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



9
10
11
# File 'lib/caution_tape/middleware.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/caution_tape/middleware.rb', line 13

def call(env)
  status, headers, body = @app.call(env)
  config = CautionTape.configuration
  return [status, headers, body] unless config.enabled && html?(headers)

  inject(status, headers, body, config)
end