# cf) xray-rails : xray/middleware.rb module CopyTunerClient class CopyrayMiddleware def initialize(app) @app = app end def call(env) status, headers, response = @app.call(env) if should_inject_xray?(status, headers, response) body = append_css!(response) body = append_js!(body) headers['Content-Length'] = body.bytesize.to_s end [status, headers, (body ? [body] : response)] end private def helpers ActionController::Base.helpers end def append_css!(response) response.body.sub(/
]*>/) { "#{$~}\n#{css_tag}" } end def append_js!(html) regexp = if ::Rails.application.config.assets.debug # Matches: # # # / /