Sha256: 81502b43b034b7b9e3d6bd80700b54f8336b6cce64521ebbfbe0fe62e35fd553

Contents?: true

Size: 939 Bytes

Versions: 24

Compression:

Stored size: 939 Bytes

Contents

require 'forwardable'

module Honeybadger
  module Rack
    class UserInformer
      extend Forwardable

      def initialize(app, config)
        @app = app
        @config = config
      end

      def replacement(with)
        config[:'user_informer.info'].gsub(/\{\{\s*error_id\s*\}\}/, with.to_s)
      end

      def call(env)
        status, headers, body = @app.call(env)
        if env['honeybadger.error_id']
          new_body = []
          replace  = replacement(env['honeybadger.error_id'])
          body.each do |chunk|
            new_body << chunk.gsub("<!-- HONEYBADGER ERROR -->", replace)
          end
          body.close if body.respond_to?(:close)
          headers['Content-Length'] = new_body.reduce(0) { |a,e| a += e.bytesize }.to_s
          body = new_body
        end
        [status, headers, body]
      end

      private

      attr_reader :config
      def_delegator :@config, :logger
    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
honeybadger-2.7.2 lib/honeybadger/rack/user_informer.rb
honeybadger-2.7.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.7.0 lib/honeybadger/rack/user_informer.rb
honeybadger-2.6.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.6.0 lib/honeybadger/rack/user_informer.rb
honeybadger-2.5.3 lib/honeybadger/rack/user_informer.rb
honeybadger-2.5.2 lib/honeybadger/rack/user_informer.rb
honeybadger-2.5.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.5.0 lib/honeybadger/rack/user_informer.rb
honeybadger-2.4.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.4.0 lib/honeybadger/rack/user_informer.rb
honeybadger-2.3.3 lib/honeybadger/rack/user_informer.rb
honeybadger-2.3.2 lib/honeybadger/rack/user_informer.rb
honeybadger-2.3.2.beta.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.3.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.3.0 lib/honeybadger/rack/user_informer.rb
honeybadger-2.2.0 lib/honeybadger/rack/user_informer.rb
honeybadger-2.2.0.beta.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.1.6.beta.1 lib/honeybadger/rack/user_informer.rb
honeybadger-2.1.5 lib/honeybadger/rack/user_informer.rb