Class: StackifyRubyAPM::Context::Request::Headers Private

Inherits:
Object
  • Object
show all
Includes:
NaivelyHashable
Defined in:
lib/stackify_apm/context/request/headers.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NaivelyHashable

#naively_hashable?, #to_h

Constructor Details

#initialize(req) ⇒ Headers

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Headers.



12
13
14
# File 'lib/stackify_apm/context/request/headers.rb', line 12

def initialize(req)
  @values = build_headers req
end

Instance Attribute Details

#valuesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/stackify_apm/context/request/headers.rb', line 16

def values
  @values
end

Instance Method Details

#build_headers(req) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
23
24
25
26
# File 'lib/stackify_apm/context/request/headers.rb', line 18

def build_headers req
  env = req.env
  headers = Hash[*env.select {|k,v| k.start_with? 'HTTP_'}
    .collect {|k,v| [k.sub(/^HTTP_/, ''), v]}
    .collect {|k,v| [k.split('_').collect(&:capitalize).join('-'), v]}
    .sort
    .flatten]
  return headers
end