Class: Airbrake::Rack::HttpHeadersFilter
- Inherits:
-
Object
- Object
- Airbrake::Rack::HttpHeadersFilter
- Defined in:
- lib/airbrake/rack/http_headers_filter.rb
Overview
Adds HTTP request parameters.
Constant Summary collapse
- HTTP_HEADER_PREFIXES =
Returns the prefixes of the majority of HTTP headers in Rack (some prefixes match the header names for simplicity).
%w[ HTTP_ CONTENT_TYPE CONTENT_LENGTH ].freeze
Instance Attribute Summary collapse
- #weight ⇒ Integer readonly
Instance Method Summary collapse
- #call(notice) ⇒ Object
-
#initialize ⇒ HttpHeadersFilter
constructor
A new instance of HttpHeadersFilter.
Constructor Details
#initialize ⇒ HttpHeadersFilter
Returns a new instance of HttpHeadersFilter.
20 21 22 |
# File 'lib/airbrake/rack/http_headers_filter.rb', line 20 def initialize @weight = 98 end |
Instance Attribute Details
#weight ⇒ Integer (readonly)
18 19 20 |
# File 'lib/airbrake/rack/http_headers_filter.rb', line 18 def weight @weight end |
Instance Method Details
#call(notice) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/airbrake/rack/http_headers_filter.rb', line 25 def call(notice) return unless (request = notice.stash[:rack_request]) http_headers = request.env.map.with_object({}) do |(key, value), headers| if HTTP_HEADER_PREFIXES.any? { |prefix| key.to_s.start_with?(prefix) } headers[key] = value end headers end notice[:context].merge!( httpMethod: request.request_method, referer: request.referer, headers: http_headers, ) end |