Class: Nacelle::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



8
9
10
# File 'lib/nacelle/middleware.rb', line 8

def initialize app
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/nacelle/middleware.rb', line 12

def call env
  status, headers, body = @app.call env
  return [status, headers, body] unless headers["Content-Type"].try(:include?, "text/html")

  new_body = ""
  body.each { |part| new_body << part }
  process! new_body, env
  headers.delete("Content-Length")
  [status, headers, [new_body]]
end