Sha256: 8430d5ed413612a27b374c505cc35e70e8c411eacde32ea02ca92d1a97fbb6a9
Contents?: true
Size: 804 Bytes
Versions: 4
Compression:
Stored size: 804 Bytes
Contents
module ProjectlockerErrata class UserInformer def initialize(app) @app = app end def replacement(with) ProjectlockerErrata.configuration.user_information.gsub(/\{\{\s*error_id\s*\}\}/, with.to_s) end def call(env) status, headers, body = @app.call(env) if env['projectlocker_errata.error_id'] && ProjectlockerErrata.configuration.user_information new_body = [] replace = replacement(env['projectlocker_errata.error_id']) body.each do |chunk| new_body << chunk.gsub("<!-- PROJECTLOCKER_ERRATA ERROR -->", replace) end body.close if body.respond_to?(:close) headers['Content-Length'] = new_body.sum(&:bytesize).to_s body = new_body end [status, headers, body] end end end
Version data entries
4 entries across 4 versions & 1 rubygems