HerokuHeader

Rack middleware that will insert Heroku's navigation header on a specified subdomain.

Installation

Add this line to your application's Gemfile:

gem 'heroku_header'

And then execute:

$ bundle

Or install it yourself as:

$ gem install heroku_header

Usage

HerokuHeader::MiddleWare takes a few config options, all optional:

  • :subdomain => The subdomain to show the header on, defaults to heroku.
  • :timeout => How many seconds until the request to get the header is cancelled, default is 5. (It fails silently when it can't fetch the header).
  • :cache => This expects an object which conforms to the ActiveSupport::Cache::Store API. It is not reccomended to leave this out, in which case the header will be fetched from Heroku on each request (when required).
  • :cache_key => This is the key which is used to store and retrieve the header from :cache. Defaults to 'heroku_header_html'.

Rails

# application.rb
config.middleware.use HerokuHeader::MiddleWare, :subdomain => 'heroku', :timeout => 5, :cache => lambda { Rails.cache }

Sinatra

require 'sinatra'

use HerokuHeader::MiddleWare, :subdomain => 'heroku', :timeout => 5

get '/' do
  ....
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request