Module: AppMap::Rails::RequestHandler
- Defined in:
- lib/appmap/rails/request_handler.rb
Defined Under Namespace
Classes: HTTPServerRequest, HTTPServerResponse, HookMethod
Constant Summary collapse
- IGNORE_HEADERS =
Host and User-Agent will just introduce needless variation. Content-Type and Authorization get their own fields in the request.
%w[host user_agent content_type authorization].map(&:upcase).map {|h| "HTTP_#{h}"}.freeze
Class Method Summary collapse
Class Method Details
.selected_headers(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/appmap/rails/request_handler.rb', line 14 def selected_headers(env) # Rack prepends HTTP_ to all client-sent headers. matching_headers = env .select { |k,v| k.start_with? 'HTTP_'} .reject { |k,v| IGNORE_HEADERS.member?(k) } .reject { |k,v| v.blank? } .each_with_object({}) do |kv, memo| key = kv[0].sub(/^HTTP_/, '').split('_').map(&:capitalize).join('-') value = kv[1] memo[key] = value end matching_headers.blank? ? nil : matching_headers end |