Class: InfluxReporter::ErrorMessage::HTTP
- Inherits:
-
Struct
- Object
- Struct
- InfluxReporter::ErrorMessage::HTTP
- Defined in:
- lib/influx_reporter/error_message/http.rb
Constant Summary collapse
- HTTP_ENV_KEY =
/^HTTP_/
- UNDERSCORE =
'_'
- DASH =
'-'
- QUESTION =
'?'
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#data ⇒ Object
Returns the value of attribute data.
-
#env ⇒ Object
Returns the value of attribute env.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#http_host ⇒ Object
Returns the value of attribute http_host.
-
#method ⇒ Object
Returns the value of attribute method.
-
#query_string ⇒ Object
Returns the value of attribute query_string.
-
#remote_host ⇒ Object
Returns the value of attribute remote_host.
-
#secure ⇒ Object
Returns the value of attribute secure.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def @cookies end |
#data ⇒ Object
Returns the value of attribute data
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def data @data end |
#env ⇒ Object
Returns the value of attribute env
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def env @env end |
#headers ⇒ Object
Returns the value of attribute headers
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def headers @headers end |
#http_host ⇒ Object
Returns the value of attribute http_host
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def http_host @http_host end |
#method ⇒ Object
Returns the value of attribute method
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def method @method end |
#query_string ⇒ Object
Returns the value of attribute query_string
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def query_string @query_string end |
#remote_host ⇒ Object
Returns the value of attribute remote_host
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def remote_host @remote_host end |
#secure ⇒ Object
Returns the value of attribute secure
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def secure @secure end |
#url ⇒ Object
Returns the value of attribute url
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def url @url end |
#user_agent ⇒ Object
Returns the value of attribute user_agent
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def user_agent @user_agent end |
#uuid ⇒ Object
Returns the value of attribute uuid
5 6 7 |
# File 'lib/influx_reporter/error_message/http.rb', line 5 def uuid @uuid end |
Class Method Details
.from_rack_env(env, opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/influx_reporter/error_message/http.rb', line 15 def self.from_rack_env(env, opts = {}) req = if defined?(ActionDispatch::Request) && env.is_a?(ActionDispatch::Request) env else Rack::Request.new env end http = new( req.url.split(QUESTION).first, # url req.request_method, # method nil, # data req.query_string, # query string env['HTTP_COOKIE'], # cookies {}, # headers req.ip, # remote host req.host_with_port, # http host req.user_agent, # user agent req.scheme == 'https', # secure {}, # env req.respond_to?(:uuid) ? req.uuid : nil ) # In Rails < 5 ActionDispatch::Request inherits from Hash headers = env.respond_to?(:headers) ? env.headers : env headers.each do |k, v| next unless k.upcase == k # lower case stuff isn't relevant if k.match(HTTP_ENV_KEY) header = k.gsub(HTTP_ENV_KEY, '') .split(UNDERSCORE).map(&:capitalize).join(DASH) http.headers[header] = v.to_s else http.env[k] = v.to_s end end if req.form_data? http.data = req.POST elsif req.body http.data = req.body.read req.body.rewind end if filter = opts[:filter] http.apply_filter filter end http end |
Instance Method Details
#apply_filter(filter) ⇒ Object
66 67 68 69 70 |
# File 'lib/influx_reporter/error_message/http.rb', line 66 def apply_filter(filter) self.data = filter.apply data self.query_string = filter.apply query_string self. = filter.apply end |