Created
October 30, 2012 18:59
-
-
Save ryansmith3136/3982276 to your computer and use it in GitHub Desktop.
Middleware to respond to HTTP HEAD /
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add this file to /lib/health.rb | |
| # Require in config/application.rb | |
| # require File.join(File.dirname(__FILE__), '../lib/health.rb') | |
| # Load in config/application.rb | |
| # config.middleware.use Heroku::HttpHealth | |
| # Be sure to put this middleware at the front of all other middlewares. Don't want authentication on this guy. | |
| class Heroku::HttpHealth | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| if env["PATH_INFO"] =~ /\A\/?\z/ && env["REQUEST_METHOD"] == "HEAD" | |
| [200, {"Content-Type" => "text/plain"}, ["OK"]] | |
| else | |
| @app.call(env) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment