Class: Sentry::RequestInterface

Inherits:
Interface show all
Defined in:
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.



15
16
17
18
19
# File 'lib/sentry/interfaces/request.rb', line 15

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

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



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

def cookies
  @cookies
end

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#envObject

Returns the value of attribute env.



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

def env
  @env
end

#headersObject

Returns the value of attribute headers.



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

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



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

def method
  @method
end

#query_stringObject

Returns the value of attribute query_string.



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

def query_string
  @query_string
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#from_rack(env_hash) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sentry/interfaces/request.rb', line 21

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