Module: Radar::DataExtensions::RequestHelper
Overview
A mixin which contains helper methods for dealing with request objects.
Instance Method Summary collapse
-
#extract_http_headers(env) ⇒ Hash
Extracts only the HTTP headers from the rack environment, converting them to the proper HTTP format:
HTTP_CONTENT_TYPE
toContent-Type
.
Instance Method Details
#extract_http_headers(env) ⇒ Hash
Extracts only the HTTP headers from the rack environment,
converting them to the proper HTTP format: HTTP_CONTENT_TYPE
to Content-Type
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/radar/data_extensions/request_helper.rb', line 12 def extract_http_headers(env) env.inject({}) do |acc, data| k, v = data if k =~ /^HTTP_(.+)$/ # Convert things like HTTP_CONTENT_TYPE to Content-Type (standard # HTTP header style) k = $1.to_s.split("_").map { |c| c.capitalize }.join("-") acc[k] = v end acc end end |