class RogerW3cvalidator::Middleware
Public Class Methods
new(app)
click to toggle source
# File lib/roger_w3cvalidator/middleware.rb, line 7 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/roger_w3cvalidator/middleware.rb, line 11 def call(env) resp = @app.call(env) if resp[1]["Content-Type"].to_s.include?("html") str = "" resp[2].each{|c| str << c} validator = W3CValidator.new(str) validator.validate! if !validator.valid env["rack.errors"].puts "Validation failed on #{env["PATH_INFO"]}: (errors: #{validator.errors}, warnings: #{validator.warnings})" end end resp end