Class: Errordeck::Request
- Inherits:
-
Object
- Object
- Errordeck::Request
- Defined in:
- lib/errordeck/errordeck/issue/request.rb
Constant Summary collapse
- HEADERS =
%w[HOST USER-AGENT ACCEPT ACCEPT_LANGUAGE ACCEPT_ENCODING CONNECTION CACHE_CONTROL UPGRADE_INSECURE_REQUESTS DNT SEC_FETCH_SITE SEC_FETCH_MODE SEC_FETCH_USER SEC_FETCH_DEST REFERER].freeze
- COOKIE =
%w[COOKIE].freeze
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.
-
#method ⇒ Object
Returns the value of attribute method.
-
#query_string ⇒ Object
Returns the value of attribute query_string.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .parse_from_rack_env(env) ⇒ Object
- .parse_from_request_handler(request) ⇒ Object
- .split_to_has_on(resource, split = ";") ⇒ Object
Instance Method Summary collapse
- #as_json(*_options) ⇒ Object
-
#initialize(url, method, data, query_string, cookies, headers, env) ⇒ Request
constructor
A new instance of Request.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(url, method, data, query_string, cookies, headers, env) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 19 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 11 def initialize(url, method, data, query_string, , headers, env) @url = Scrubber::Url.new(url).scrub @method = method @data = data @query_string = Scrubber::QueryParam.new(query_string).scrub = Scrubber::Cookie.new().scrub @headers = Scrubber::Header.new(headers.transform_keys { |k| k.to_s.gsub("HTTP_", "").gsub("_", "-") }).scrub @env = env end |
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
5 6 7 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 5 def end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 5 def data @data end |
#env ⇒ Object
Returns the value of attribute env.
5 6 7 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 5 def env @env end |
#headers ⇒ Object
Returns the value of attribute headers.
5 6 7 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 5 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
5 6 7 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 5 def method @method end |
#query_string ⇒ Object
Returns the value of attribute query_string.
5 6 7 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 5 def query_string @query_string end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 5 def url @url end |
Class Method Details
.parse_from_rack_env(env) ⇒ Object
21 22 23 24 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 21 def self.parse_from_rack_env(env) request = RequestHandler.parse_from_rack_env(env) new(request.url, request.method, nil, request.query_string, request., request.headers, env) end |
.parse_from_request_handler(request) ⇒ Object
26 27 28 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 26 def self.parse_from_request_handler(request) new(request.url, request.method, nil, request.query_string, request., request.headers, nil) end |
.split_to_has_on(resource, split = ";") ⇒ Object
30 31 32 33 34 35 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 30 def self.split_to_has_on(resource, split = ";") resource.split(split).each_with_object({}) do |item, hash| key, value = item.split("=").map(&:strip) hash[key] = value end end |
Instance Method Details
#as_json(*_options) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 41 def as_json(*) { url: @url, method: @method, query_string: @query_string, headers: headers } end |
#to_json(*options) ⇒ Object
50 51 52 |
# File 'lib/errordeck/errordeck/issue/request.rb', line 50 def to_json(*) JSON.generate(as_json, *) end |