lib/admin_it/middleware.rb in admin_it-1.2.3 vs lib/admin_it/middleware.rb in admin_it-1.2.4

- old
+ new

@@ -31,23 +31,25 @@ end end # AdminIt middleware class Middleware - SUBST_REGEXP = /<!--\s*([a-zA-Z0-9_]+)\s*-->/ + SUBST_REGEXP = /<!--\s*(?<name>[a-zA-Z0-9_]+)\s*-->/ def initialize(app) @app = app end def call(env) request = env[Request::ENV_KEY] = Request.new(env) status, headers, body = @app.call(env) if request.process? + length = 0 body.each do |str| - # $1 not working here ??? str.gsub!(SUBST_REGEXP) { |s| request[SUBST_REGEXP.match(s)[1]] } + length += str.size end + headers['Content-Length'] = length.to_s end [status, headers, body] end end end