Class: ValidateHTML::RackMiddleware
- Inherits:
-
Object
- Object
- ValidateHTML::RackMiddleware
- Defined in:
- lib/validate_html/rack_middleware.rb
Overview
Rack Middleware to validate the HTML of outgoing responses
This can be used with any rack app
Instance Method Summary collapse
- #call(env) ⇒ Array<(status, headers, response)>
-
#initialize(app) ⇒ RackMiddleware
constructor
A new instance of RackMiddleware.
Constructor Details
#initialize(app) ⇒ RackMiddleware
Returns a new instance of RackMiddleware.
8 9 10 |
# File 'lib/validate_html/rack_middleware.rb', line 8 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Array<(status, headers, response)>
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/validate_html/rack_middleware.rb', line 19 def call(env) status, headers, response = @app.call(env) path = ::Rack::Request.new(env).path return [status, headers, response] unless checkable_path?(path) body = find_body(response) return [status, headers, response] unless html_content_type?(headers) ValidateHTML.validate_html(body, content_type: headers['Content-Type'], name: path) [status, headers, response] end |