Project

sha_header

0.01
No commit activity in last 3 years
No release in over 3 years
This library adds a new, custom X-Git-SHA header to your Rails application's response which contains the SHA hash that your application is currently running.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 2.0
~> 1.0
~> 13.0
~> 3.0

Runtime

>= 3.2, < 6.1
 Project Readme

🚧 This library has been replaced by Rapporteur. 🚧

Rapporteur provides similar functionality, although rather than injecting the revision information into every request as sha_header does, it provides a status endpoint where you can provide multiple server data points (Git revision, system time, uptime, whatever).

SHAHeader

Gem Version Build Status

SHAHeader is a simple Rack middleware gem for Rails. When required, it will instruct Rails to automatically insert its middleware into the Rack stack and inject your current git SHA hash into all of your dynamic response headers.

Compatibility

The SHAHeader gem is compatible with:

  • Ruby 2.4, 2.5, and 2.6 and
  • Rails 5.2 and 6.0.

This library may continue to be compatible with older versions (Ruby 2.1+, Rails 3.2+), however those versions have been end-of-life'd and are no longer maintained by their authors.

Installation

In Rails, modify your Gemfile to add the following line:

gem 'sha_header', '~> 1.0'

That's it. It is distributed with a Railtie to instruct Rails on how to set it up, so no other coding is required.

Example

Here's a simple example for a Rails application running locally. The application has added the above Gemfile line. Using curl:

curl -I http://localhost:3000/

And, the following response is received:

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
ETag: "25ec427afba8daa376f309559b1b3c5c"
Cache-Control: max-age=0, private, must-revalidate
X-Git-SHA: 8c139c519c731be597d0c37a6e5ce46a27bab174
X-UA-Compatible: IE=Edge
X-Runtime: 0.120340
Content-Length: 0
Connection: Keep-Alive

(Notice the X-Git-SHA header)