Sha256: 22e92669dbb7009230c60aee813a72116bebfd25072968187012f2c29edd9fcc

Contents?: true

Size: 907 Bytes

Versions: 81

Compression:

Stored size: 907 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The early_hints plugin allows sending 103 Early Hints responses
    # using the rack.early_hints environment variable.  Currently, this
    # is only supported by puma 3.11+, and on other servers this is a no-op.
    # Early hints allow clients to preload necessary files before receiving
    # the response.
    module EarlyHints
      module InstanceMethods
        # Send given hash of Early Hints using the rack.early_hints environment variable,
        # currenly only supported by puma.  hash given should generally have the single
        # key 'Link', and a string or array of strings for each of the early hints.
        def send_early_hints(hash)
          if eh_proc = env['rack.early_hints']
            eh_proc.call(hash)
          end
        end
      end
    end

    register_plugin(:early_hints, EarlyHints)
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
roda-3.85.0 lib/roda/plugins/early_hints.rb
roda-3.84.0 lib/roda/plugins/early_hints.rb
roda-3.83.0 lib/roda/plugins/early_hints.rb
roda-3.82.0 lib/roda/plugins/early_hints.rb
roda-3.81.0 lib/roda/plugins/early_hints.rb
roda-3.79.0 lib/roda/plugins/early_hints.rb
roda-3.78.0 lib/roda/plugins/early_hints.rb
roda-3.77.0 lib/roda/plugins/early_hints.rb
roda-3.76.0 lib/roda/plugins/early_hints.rb
roda-3.75.0 lib/roda/plugins/early_hints.rb
roda-3.74.0 lib/roda/plugins/early_hints.rb
roda-3.73.0 lib/roda/plugins/early_hints.rb
roda-3.72.0 lib/roda/plugins/early_hints.rb
roda-3.71.0 lib/roda/plugins/early_hints.rb
roda-3.70.0 lib/roda/plugins/early_hints.rb
roda-3.69.0 lib/roda/plugins/early_hints.rb
roda-3.68.0 lib/roda/plugins/early_hints.rb
roda-3.67.0 lib/roda/plugins/early_hints.rb
roda-3.66.0 lib/roda/plugins/early_hints.rb
roda-3.65.0 lib/roda/plugins/early_hints.rb