Class: Regal::Request
- Inherits:
-
Object
- Object
- Regal::Request
- Defined in:
- lib/regal/request.rb
Instance Attribute Summary collapse
- #attributes ⇒ Hash readonly
- #env ⇒ Hash readonly
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Hash (readonly)
9 10 |
# File 'lib/regal/request.rb', line 9 attr_reader :env, :attributes |
#env ⇒ Hash (readonly)
|
# File 'lib/regal/request.rb', line 3
|
Instance Method Details
#body ⇒ IO
50 51 52 |
# File 'lib/regal/request.rb', line 50 def body @env[RACK_INPUT_KEY] end |
#headers ⇒ Hash
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/regal/request.rb', line 29 def headers @headers ||= begin headers = @env.each_with_object({}) do |(key, value), headers| if key.start_with?(HEADER_PREFIX) normalized_key = key[HEADER_PREFIX.length, key.length - HEADER_PREFIX.length] normalized_key.gsub!(/(?<=^.|_.)[^_]+/) { |str| str.downcase } normalized_key.gsub!('_', '-') elsif key == CONTENT_LENGTH_KEY normalized_key = CONTENT_LENGTH_HEADER elsif key == CONTENT_TYPE_KEY normalized_key = CONTENT_TYPE_HEADER end if normalized_key headers[normalized_key] = value end end headers.freeze end end |
#parameters ⇒ Hash
20 21 22 23 24 25 26 |
# File 'lib/regal/request.rb', line 20 def parameters @parameters ||= begin query = Rack::Utils.parse_query(@env[QUERY_STRING_KEY], PARAMETER_SEPARATORS) query.merge!(@path_captures) query.freeze end end |