Sha256: f4019e1816c8e697be4d0bbf56ead527fbf5bc3855814db1625436f86ca970f2

Contents?: true

Size: 1013 Bytes

Versions: 11

Compression:

Stored size: 1013 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The response_headers_plain_hash 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

11 entries across 11 versions & 1 rubygems

Version Path
roda-3.81.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.79.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.78.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.77.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.76.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.75.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.74.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.73.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.72.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.71.0 lib/roda/plugins/plain_hash_response_headers.rb
roda-3.70.0 lib/roda/plugins/plain_hash_response_headers.rb