Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 License.txt
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 add_http_header.gemspec
README.rdoc

AddHttpHeader

This gem provides Rack middleware which adds an http header to the response. You can either add a hard coded header, or provide a block that will get evaluated at runtime.

Example

# Add the host and build version to the header to make debugging production issues easier
host_info = "#{`hostname`.split('.').first}; #{BUILD_VERSION}"
Rails.configuration.middleware.insert_before(0, AddHttpHeader, 'X-Host-Info' => host_info)

# Add debug info about the request only on errors
Rails.configuration.middleware.insert_before(0, AddHttpHeader, 'X-Debug' => lambda{|env, status, headers| DebugInfo(env) if status >= 500})
Something went wrong with that request. Please try again.