Class: Flame::Dispatcher::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Flame::Dispatcher::Request
- Includes:
- Memery
- Defined in:
- lib/flame/dispatcher/request.rb
Overview
Class for requests
Constant Summary collapse
- HEADER_PREFIX =
'HTTP_'
Instance Method Summary collapse
-
#headers ⇒ Object
Helper method for comfortable Camel-Cased Hash of headers.
-
#http_method ⇒ Object
Override HTTP-method of the request if the param ‘_method’ found.
-
#path ⇒ Object
Initialize Flame::Path.
Instance Method Details
#headers ⇒ Object
Helper method for comfortable Camel-Cased Hash of headers
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/flame/dispatcher/request.rb', line 32 memoize def headers env.each_with_object({}) do |(key, value), result| next unless key.start_with?(HEADER_PREFIX) camelized_key = key.delete_prefix(HEADER_PREFIX).downcase.tr('_', '/').camelize.gsub('::', '-') result[camelized_key] = value end end |
#http_method ⇒ Object
Override HTTP-method of the request if the param ‘_method’ found
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flame/dispatcher/request.rb', line 15 memoize def http_method method_from_method = begin params['_method'] rescue ArgumentError => e ## https://github.com/rack/rack/issues/337#issuecomment-48555831 raise unless e..include?('invalid %-encoding') end (method_from_method || request_method).upcase.to_sym end |