lib/web_console/request.rb in web-console-2.2.0 vs lib/web_console/request.rb in web-console-2.2.1
- old
+ new
@@ -8,10 +8,13 @@
# Configurable set of whitelisted networks.
cattr_accessor :whitelisted_ips
@@whitelisted_ips = Whitelist.new
+ # Define a vendor MIME type. We can call it using Mime::WEB_CONSOLE_V2 constant.
+ Mime::Type.register 'application/vnd.web-console.v2', :web_console_v2
+
# Returns whether a request came from a whitelisted IP.
#
# For a request to hit Web Console features, it needs to come from a white
# listed IP.
def from_whitelited_ip?
@@ -28,9 +31,14 @@
# We can render a console for HTML and TEXT by default. If a client didn't
# specified any content type and the server returned it as blank, we'll
# render it as well.
def acceptable_content_type?
content_type.blank? || content_type.in?(acceptable_content_types)
+ end
+
+ # Returns whether the request is acceptable.
+ def acceptable?
+ xhr? && accepts.any? { |mime| Mime::WEB_CONSOLE_V2 == mime }
end
class GetSecureIp < ActionDispatch::RemoteIp::GetIp
def initialize(env, proxies)
@env = env