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.



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

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.



18
19
20
# File 'lib/datadog/tracing/contrib/rack/header_collection.rb', line 18

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)


26
27
28
# File 'lib/datadog/tracing/contrib/rack/header_collection.rb', line 26

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