No commit activity in last 3 years
No release in over 3 years
Add rel=preload headers to Rack applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 5.0
~> 1.6
~> 10.0
~> 1.4
 Project Readme

RackHttpPreload

Requires Ruby 2.0+.

rack_http_preload is only compatible with Rack apps that provide a response object. This response object should be compatible with Rack::Response, namely it should provide response.headers=.

require "rack"

class MyTestRackApp
  include RackHttpPreload
  attr_accessor :response

  def call(env)
    self.response = Rack::Response.new("Hello World!", 200, {})
    # If MIME::Types is available, this gem guesses the appropriate `as` and `type`
    http_preload "application.js"
    response.finish
  end

  # "Link"=>"<application.js>; rel=preload; as=script"
end