Module: RackHttpPreload

Defined in:
lib/rack_http_preload.rb,
lib/rack_http_preload/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#http_preload(path = nil, crossorigin: false, push: false, as: nil, type: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rack_http_preload.rb', line 5

def http_preload path = nil, crossorigin: false, push: false, as: nil, type: nil
  as, type = guess_http_preload_opts(path) if (as.nil? && type.nil?)

  header = ["<#{path}>", "rel=preload"]
  header << "as=#{as}" if as
  header << "crossorigin" if crossorigin
  header << "nopush" if push
  header << "type='#{type}'" if type

  add_to_link_header header.join("; ")
end