module Roda::RodaPlugins::Public

def self.configure(app, opts={})

for clients supporting "zstd" transfer encoding.
:zstd :: Whether to serve already zstd-compressed files with a .zst extension
:root :: Use this option for the root of the public directory (default: "public")
:headers :: A hash of headers to use for statically served files
supporting "gzip" transfer encoding.
:gzip :: Whether to serve already gzipped files with a .gz extension for clients
precedence over the :brotli, :gzip, and :zstd options if given.
encodings other than zstd, brotli, and gzip. This takes
are tried, to prefer brotli to zstd for example, or to support
'.gz'). This allows configuration of the order in which encodings
and the second element of the pair is the file extension (e.g.
element of the pair is the accepted encoding name (e.g. 'gzip'),
:encodings :: An enumerable of pairs to handle accepted encodings. The first
:default_mime :: The default mime type to use if the mime type is not recognized.
for clients supporting "br" transfer encoding.
:brotli :: Whether to serve already brotli-compressed files with a .br extension
Use options given to setup a Rack::File instance for serving files. Options:
def self.configure(app, opts={})
  if opts[:root]
    app.opts[:public_root] = app.expand_path(opts[:root])
  elsif !app.opts[:public_root]
    app.opts[:public_root] = app.expand_path("public")
  end
  app.opts[:public_server] = RACK_FILES.new(app.opts[:public_root], opts[:headers]||{}, opts[:default_mime] || 'text/plain')
  unless encodings = opts[:encodings]
    if ENCODING_MAP.any?{|k,| opts.has_key?(k)}
      encodings = ENCODING_MAP.map{|k, v| [v, ENCODING_EXTENSIONS[v]] if opts[k]}.compact
    end
  end
  encodings = (encodings || app.opts[:public_encodings] || EMPTY_ARRAY).map(&:dup).freeze
  encodings.each do |a|
    a << /\b#{a[0]}\b/
  end
  encodings.each(&:freeze)
  app.opts[:public_encodings] = encodings
end