Module: GrapeRailsLogger::EndpointPatch

Defined in:
lib/grape_rails_logger/endpoint_patch.rb

Overview

Monkey patch Grape::Endpoint#build_stack to wrap the final Rack app This ensures we capture the response AFTER Error middleware has fully processed it

Instance Method Summary collapse

Instance Method Details

#build_stack(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/grape_rails_logger/endpoint_patch.rb', line 5

def build_stack(*args)
  app = super
  # Wrap the final Rack app to capture responses after Error middleware
  if ::GrapeRailsLogger.effective_config.enabled
    ::GrapeRailsLogger::EndpointWrapper.new(app, self)
  else
    app
  end
end