Class: RubberDuck::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rubber_duck/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



6
7
8
9
# File 'lib/rubber_duck/middleware.rb', line 6

def initialize(app)
  @app = app
  @model_name = RubberDuck.configuration.model
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rubber_duck/middleware.rb', line 11

def call(env)
  status, headers, response = @app.call(env)

  # Debug logging
  # Rails.logger.info "RubberDuck: status=#{status}, content_type=#{headers['Content-Type']}, dev=#{Rails.env.development?}, enabled=#{RubberDuck.configuration.enabled}"

  # Only intercept in development mode
  if should_inject?(env, status, headers)
    # Rails.logger.info "RubberDuck: Replacing response with custom error page"
    return inject_button_response(env, status, headers, response)
  end

  [ status, headers, response ]
end