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.25.0 lib/roda/plugins/early_hints.rb
roda-3.24.0 lib/roda/plugins/early_hints.rb
roda-3.23.0 lib/roda/plugins/early_hints.rb
roda-3.22.0 lib/roda/plugins/early_hints.rb
roda-3.21.0 lib/roda/plugins/early_hints.rb
roda-3.20.0 lib/roda/plugins/early_hints.rb
roda-3.19.0 lib/roda/plugins/early_hints.rb
roda-3.18.0 lib/roda/plugins/early_hints.rb
roda-3.17.0 lib/roda/plugins/early_hints.rb
roda-3.16.0 lib/roda/plugins/early_hints.rb
roda-3.15.0 lib/roda/plugins/early_hints.rb
roda-3.14.1 lib/roda/plugins/early_hints.rb
roda-3.14.0 lib/roda/plugins/early_hints.rb
roda-3.13.0 lib/roda/plugins/early_hints.rb
roda-3.12.0 lib/roda/plugins/early_hints.rb
roda-3.11.0 lib/roda/plugins/early_hints.rb
roda-3.10.0 lib/roda/plugins/early_hints.rb
roda-3.9.0 lib/roda/plugins/early_hints.rb
roda-3.8.0 lib/roda/plugins/early_hints.rb
roda-3.7.0 lib/roda/plugins/early_hints.rb