Class: Datadog::Tracing::Contrib::Rack::Header::RequestHeaderCollection

Inherits:
Core::HeaderCollection show all
Defined in:
lib/datadog/tracing/contrib/rack/header_collection.rb

Overview

An implementation of a header collection that looks up headers from a Rack environment.

Instance Method Summary collapse

Methods inherited from Core::HeaderCollection

from_hash

Constructor Details

#initialize(env) ⇒ RequestHeaderCollection

Creates a header collection from a rack environment.



14
15
16
17
# File 'lib/datadog/tracing/contrib/rack/header_collection.rb', line 14

def initialize(env)
  super()
  @env = env
end

Instance Method Details

#get(header_name) ⇒ Object Also known as: []

Gets the value of the header with the given name.



20
21
22
# File 'lib/datadog/tracing/contrib/rack/header_collection.rb', line 20

def get(header_name)
  @env[Header.to_rack_header(header_name)]
end

#key?(header_name) ⇒ Boolean

Tests whether a header with the given name exists in the environment.

Returns:

  • (Boolean)


28
29
30
# File 'lib/datadog/tracing/contrib/rack/header_collection.rb', line 28

def key?(header_name)
  @env.key?(Header.to_rack_header(header_name))
end