Sha256: 2ee5c042c2d7f6a466907cfeb2718731ce79ff32b1fec77be2bcbd2e7bfee37d

Contents?: true

Size: 1.05 KB

Versions: 15

Compression:

Stored size: 1.05 KB

Contents

require_relative '../../../core/header_collection'

module Datadog
  module Tracing
    module Contrib
      module Rack
        # Classes and utilities for handling headers in Rack.
        module Header
          # An implementation of a header collection that looks up headers from a Rack environment.
          class RequestHeaderCollection < Datadog::Core::HeaderCollection
            # Creates a header collection from a rack environment.
            def initialize(env)
              super()
              @env = env
            end

            # Gets the value of the header with the given name.
            def get(header_name)
              @env[Header.to_rack_header(header_name)]
            end

            # Tests whether a header with the given name exists in the environment.
            def key?(header_name)
              @env.key?(Header.to_rack_header(header_name))
            end
          end

          def self.to_rack_header(name)
            "HTTP_#{name.to_s.upcase.gsub(/[-\s]/, '_')}"
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ddtrace-1.12.1 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.12.0 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.11.1 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.11.0 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.11.0.beta1 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.10.1 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.10.0 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.9.0 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.8.0 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.7.0 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.6.1 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.6.0 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.5.2 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.5.1 lib/datadog/tracing/contrib/rack/header_collection.rb
ddtrace-1.5.0 lib/datadog/tracing/contrib/rack/header_collection.rb