Class: WebConsole::WhinyRequest

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/web_console/whiny_request.rb

Overview

Noisy wrapper around Request.

If any calls to from_whitelisted_ip? and acceptable_content_type? return false, an info log message will be displayed in users’ logs.

Instance Method Summary collapse

Instance Method Details

#acceptable_content_type?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
# File 'lib/web_console/whiny_request.rb', line 14

def acceptable_content_type?
  whine_unless request.acceptable_content_type? do
    "Cannot render console with content type #{request.content_type}" \
      "Allowed content types: #{request.acceptable_content_types}"
  end
end

#from_whitelited_ip?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
# File 'lib/web_console/whiny_request.rb', line 7

def from_whitelited_ip?
  whine_unless request.from_whitelited_ip? do
    "Cannot render console from #{request.remote_ip}! " \
      "Allowed networks: #{request.whitelisted_ips}"
  end
end