Class: Mbeditor::Rack::SilencePingRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/mbeditor/rack/silence_ping_request.rb

Overview

Silence editor traffic so development logs stay readable, while leaving the initial GET to the engine root visible as a signal that a developer opened Mbeditor.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ SilencePingRequest

Returns a new instance of SilencePingRequest.



12
13
14
# File 'lib/mbeditor/rack/silence_ping_request.rb', line 12

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/mbeditor/rack/silence_ping_request.rb', line 16

def call(env)
  path = normalized_request_path(env)
  if root_request?(env, path)
    @app.call(env)
  elsif mbeditor_request?(path) || editor_asset_request?(env, path)
    Rails.logger.silence { @app.call(env) }
  else
    @app.call(env)
  end
end