Class: Sentry::RequestInterface

Inherits:
Interface show all
Defined in:
lib/sentry/rack/interface.rb,
lib/sentry/interfaces/request.rb

Constant Summary collapse

REQUEST_ID_HEADERS =
%w(action_dispatch.request_id HTTP_X_REQUEST_ID).freeze
IP_HEADERS =
[
  "REMOTE_ADDR",
  "HTTP_CLIENT_IP",
  "HTTP_X_REAL_IP",
  "HTTP_X_FORWARDED_FOR"
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Interface

inherited, registered, #to_hash

Constructor Details

#initializeRequestInterface

Returns a new instance of RequestInterface.



13
14
15
16
17
# File 'lib/sentry/interfaces/request.rb', line 13

def initialize
  self.headers = {}
  self.env = {}
  self.cookies = nil
end

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



11
12
13
# File 'lib/sentry/interfaces/request.rb', line 11

def cookies
  @cookies
end

#dataObject

Returns the value of attribute data.



11
12
13
# File 'lib/sentry/interfaces/request.rb', line 11

def data
  @data
end

#envObject

Returns the value of attribute env.



11
12
13
# File 'lib/sentry/interfaces/request.rb', line 11

def env
  @env
end

#headersObject

Returns the value of attribute headers.



11
12
13
# File 'lib/sentry/interfaces/request.rb', line 11

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



11
12
13
# File 'lib/sentry/interfaces/request.rb', line 11

def method
  @method
end

#query_stringObject

Returns the value of attribute query_string.



11
12
13
# File 'lib/sentry/interfaces/request.rb', line 11

def query_string
  @query_string
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/sentry/interfaces/request.rb', line 11

def url
  @url
end

Instance Method Details

#from_rack(env_hash) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sentry/rack/interface.rb', line 3

def from_rack(env_hash)
  req = ::Rack::Request.new(env_hash)

  if Sentry.configuration.send_default_pii
    self.data = read_data_from(req)
    self.cookies = req.cookies
  else
    # need to completely wipe out ip addresses
    IP_HEADERS.each { |h| env_hash.delete(h) }
  end

  self.url = req.scheme && req.url.split('?').first
  self.method = req.request_method
  self.query_string = req.query_string

  self.headers = format_headers_for_sentry(env_hash)
  self.env     = format_env_for_sentry(env_hash)
end