Class: LogBrew::Rails::RequestMiddleware
- Inherits:
-
Object
- Object
- LogBrew::Rails::RequestMiddleware
- Defined in:
- lib/logbrew/rails_integration.rb
Overview
Rails middleware entry point. Capture failures never call the app twice.
Instance Method Summary collapse
- #call(environment) ⇒ Object
-
#initialize(app, runtime: LogBrew::Rails.runtime) ⇒ RequestMiddleware
constructor
A new instance of RequestMiddleware.
Constructor Details
#initialize(app, runtime: LogBrew::Rails.runtime) ⇒ RequestMiddleware
Returns a new instance of RequestMiddleware.
573 574 575 576 577 578 579 580 581 582 |
# File 'lib/logbrew/rails_integration.rb', line 573 def initialize(app, runtime: LogBrew::Rails.runtime) raise SdkError.new("validation_error", "Rails app must respond to call") unless app.respond_to?(:call) raise SdkError.new("configuration_error", "LogBrew Rails runtime is not installed") if runtime.nil? @app = app @runtime = runtime @mutex = Mutex.new @adapter_client = nil @adapter = nil end |
Instance Method Details
#call(environment) ⇒ Object
584 585 586 587 588 589 590 591 592 |
# File 'lib/logbrew/rails_integration.rb', line 584 def call(environment) active_client = @runtime.client return @app.call(environment) if active_client.nil? adapter = adapter_for(active_client) return @app.call(environment) if adapter.nil? RequestOperations.within { adapter.call(environment) } end |