lib/coach/request_serializer.rb in coach-1.0.0 vs lib/coach/request_serializer.rb in coach-2.0.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Coach class RequestSerializer def self.header_rules @header_rules ||= {} end @@ -12,10 +14,11 @@ end # Applies sanitizing rules. Expects `header` to be in 'http_header_name' form. def self.apply_header_rule(header, value) return value if header_rules[header].nil? + header_rules[header].call(value) end # Resets all header sanitizing def self.clear_header_rules! @@ -37,11 +40,12 @@ format: @request.format.try(:ref), params: @request.filtered_parameters, # uses config.filter_parameters # Extra request info headers: filtered_headers, - session_id: @request.remote_ip, + session_id: @request.remote_ip, # TODO: remove in a future release + session_ip: @request.remote_ip, } end private @@ -52,9 +56,10 @@ end def filtered_headers header_value_pairs = @request.filtered_env.map do |key, value| next unless key =~ /^HTTP_/ + [key.downcase, self.class.apply_header_rule(key.downcase, value)] end.compact Hash[header_value_pairs] end