No commit activity in last 3 years
No release in over 3 years
Rack middleware: Sets response headers based on matching URL conditions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

Rack::ConditionalResponseHeaders

Rack middleware: Sets response headers based on matching URL conditions

Installation

Add this line to your application's Gemfile:

gem 'rack-conditional_response_headers'

Or install it yourself as:

$ gem install rack-conditional_response_headers

Usage

# Create a list of URL match conditions along with headers that should be applied
conditions = [] 
conditions.push	[/localhost/, {'Cache-Control'=>'no-cache'}]
conditions.push	[/\.herokuapp\.com\/?.*/, {'X-Robots-Tag'=>'noindex, nofollow'}]
conditions.push	[/.*/, {'Server'=>nil}] # Use nil to delete header

use Rack::ConditionalResponseHeaders, conditions

URL match examples:

  • /.*/ = Any URL
  • /\.herokuapp\.com\/?.*/ = Is 'herokuapp.com' domain
  • /\.pdf$|\.png$/ = Ends in '.pdf' or '.png'
  • /localhost/ = Contains 'localhost'
  • /^(?!.*localhost).*$/ = Does not contain 'localhost'