Module: FiberAudit::Runtime::RailsIntegration::ControllerHook

Defined in:
lib/fiber_audit/runtime/rails_integration.rb

Overview

Prepend hooks - consult active integration before setting context Resilient to context store failures in fail-open mode Critical: must not catch application exceptions or invoke app twice

Instance Method Summary collapse

Instance Method Details

#process_actionObject



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/fiber_audit/runtime/rails_integration.rb', line 227

def process_action(...)
  integration = RailsIntegration.current
  return super unless integration&.active_for_current_process?

  executed = false
  begin
    integration.context_store.with(:request) do
      executed = true
      super
    end
  rescue StandardError
    raise if executed
    # Context setup failed before application code ran
    raise unless integration.send(:fail_open?)

    integration.send(:account_internal_error)
    super
  end
end