Skip to content

Commit

Permalink
Don't insert middleware at all if they've been disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleypriest committed May 23, 2024
1 parent 89f9798 commit 3acd8ef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/honeybadger/init/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class Railtie < ::Rails::Railtie
end

initializer 'honeybadger.install_middleware' do |app|
honeybadger_config = Honeybadger::Agent.instance.config

app.config.middleware.insert(0, Honeybadger::Rack::ErrorNotifier)
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer)
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback)
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserInformer) if honeybadger_config[:'user_informer.enabled']
app.config.middleware.insert_before(Honeybadger::Rack::ErrorNotifier, Honeybadger::Rack::UserFeedback) if honeybadger_config[:'feedback.enabled']
end

config.before_initialize do
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/rack/user_feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def initialize(app, agent = nil)
end

def call(env)
return @app.call(env) unless config[:'feedback.enabled']
status, headers, body = @app.call(env)
if env['honeybadger.error_id'] && form = render_form(env['honeybadger.error_id'])
new_body = []
Expand Down
1 change: 0 additions & 1 deletion lib/honeybadger/rack/user_informer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def replacement(with)
end

def call(env)
return @app.call(env) unless config[:'user_informer.enabled']
status, headers, body = @app.call(env)
if env['honeybadger.error_id']
new_body = []
Expand Down

0 comments on commit 3acd8ef

Please sign in to comment.