Sha256: a617f41524bc6acf4c64167951ca5b0a8d954edfa547d6546b999be19af7137d

Contents?: true

Size: 1013 Bytes

Versions: 9

Compression:

Stored size: 1013 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The plain_hash_response_headers plugin will change Roda to
    # use a plain hash for response headers.  This is Roda's
    # default behavior on Rack 2, but on Rack 3+, Roda defaults
    # to using Rack::Headers for response headers for backwards
    # compatibility (Rack::Headers automatically lower cases header
    # keys).
    #
    # On Rack 3+, you should use this plugin for better performance
    # if you are sure all headers in your application and middleware
    # are already lower case (lower case response header keys are
    # required by the Rack 3 spec).
    module PlainHashResponseHeaders
      if defined?(Rack::Headers) && Rack::Headers.is_a?(Class)
        module ResponseMethods
          private

          # Use plain hash for headers
          def _initialize_headers
            {}
          end
        end
      end
    end

    register_plugin(:plain_hash_response_headers, PlainHashResponseHeaders)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
roda-3.90.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.89.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.88.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.87.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.86.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.85.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.84.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.83.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.82.0 lib/roda/plugins/plain_hash_response_headers.rb