Module: QNA::RequestInfoMethods
- Included in:
- Request
- Defined in:
- lib/qna/request_info.rb
Instance Method Summary collapse
- #connection ⇒ Object
- #forwarded_for ⇒ Object
- #host ⇒ Object
- #method ⇒ Object
- #path ⇒ Object
- #protocol ⇒ Object
- #query ⇒ Object
- #query_string ⇒ Object
- #request_id ⇒ Object
- #scheme ⇒ Object
- #split_query_string(query) ⇒ Object
- #upgrade_protocol ⇒ Object
- #uri ⇒ Object
Instance Method Details
#connection ⇒ Object
12 13 14 |
# File 'lib/qna/request_info.rb', line 12 def connection @headers['connection'] end |
#forwarded_for ⇒ Object
61 62 63 |
# File 'lib/qna/request_info.rb', line 61 def forwarded_for @headers['x-forwarded-for'] end |
#host ⇒ Object
8 9 10 |
# File 'lib/qna/request_info.rb', line 8 def host @headers['host'] end |
#method ⇒ Object
24 25 26 |
# File 'lib/qna/request_info.rb', line 24 def method @method ||= @headers[':method'].downcase end |
#path ⇒ Object
36 37 38 |
# File 'lib/qna/request_info.rb', line 36 def path @path ||= uri.path end |
#protocol ⇒ Object
20 21 22 |
# File 'lib/qna/request_info.rb', line 20 def protocol @protocol ||= @adapter.protocol end |
#query ⇒ Object
44 45 46 47 48 |
# File 'lib/qna/request_info.rb', line 44 def query return @query if @query @query = (q = uri.query) ? split_query_string(q) : {} end |
#query_string ⇒ Object
40 41 42 |
# File 'lib/qna/request_info.rb', line 40 def query_string @query_string ||= uri.query end |
#request_id ⇒ Object
57 58 59 |
# File 'lib/qna/request_info.rb', line 57 def request_id @headers['x-request-id'] end |
#scheme ⇒ Object
28 29 30 |
# File 'lib/qna/request_info.rb', line 28 def scheme @scheme ||= @headers[':scheme'] end |
#split_query_string(query) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/qna/request_info.rb', line 50 def split_query_string(query) query.split('&').each_with_object({}) do |kv, h| k, v = kv.split('=') h[k.to_sym] = URI.decode_www_form_component(v) end end |
#upgrade_protocol ⇒ Object
16 17 18 |
# File 'lib/qna/request_info.rb', line 16 def upgrade_protocol connection == 'upgrade' && @headers['upgrade']&.downcase end |
#uri ⇒ Object
32 33 34 |
# File 'lib/qna/request_info.rb', line 32 def uri @uri ||= URI.parse(@headers[':path'] || '') end |