Class: HtmlCompress::Middleware
- Inherits:
-
Object
- Object
- HtmlCompress::Middleware
- Defined in:
- lib/html_compress/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 |
# File 'lib/html_compress/middleware.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/html_compress/middleware.rb', line 9 def call(env) status, headers, @response = @app.call env content_type = headers['Content-Type'] compress_body! if content_type.present? && content_type.include?('text/html') [status, headers, @response] end |