Class: Debugbar::HttpRequest
- Inherits:
-
Object
- Object
- Debugbar::HttpRequest
- Defined in:
- lib/debugbar/http/http.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method, url, headers, body) ⇒ HttpRequest
constructor
A new instance of HttpRequest.
- #to_h ⇒ Object
Constructor Details
#initialize(method, url, headers, body) ⇒ HttpRequest
Returns a new instance of HttpRequest.
5 6 7 8 9 10 |
# File 'lib/debugbar/http/http.rb', line 5 def initialize(method, url, headers, body) @method = method @url = url @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/debugbar/http/http.rb', line 3 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
3 4 5 |
# File 'lib/debugbar/http/http.rb', line 3 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/debugbar/http/http.rb', line 3 def method @method end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/debugbar/http/http.rb', line 3 def url @url end |
Class Method Details
.from_rack(rack_req) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/debugbar/http/http.rb', line 12 def self.from_rack(rack_req) headers = rack_req.env.select { |k,v| k.start_with? 'HTTP_'} # https://stackoverflow.com/a/55406700/1001125 .transform_keys { |k| k.sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-') } .sort.to_h new(rack_req.method, rack_req.original_url, headers, rack_req.body) end |
Instance Method Details
#to_h ⇒ Object
20 21 22 |
# File 'lib/debugbar/http/http.rb', line 20 def to_h { method:, url:, headers:, body: } end |