Created
July 24, 2013 11:20
-
-
Save tobiashm/6069741 to your computer and use it in GitHub Desktop.
This file contains 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
Gem::Specification.new do |spec| | |
spec.name = 'ping_response' | |
spec.version = '0.1.0' | |
spec.platform = Gem::Platform::RUBY | |
spec.author = 'Tobias H. Michaelsen' | |
spec.email = '[email protected]' | |
spec.summary = 'Simple wrapper for Rack apps to add /ping response handler' | |
spec.description = 'Will wrap a regular Rack app and add a handler for /ping which responds with `pong` in text/plain' | |
spec.license = 'MIT' | |
spec.files = ['ping_response.rb'] | |
spec.require_path = '.' | |
spec.add_dependency('rack') | |
end |
This file contains 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
require 'rack' | |
module PingResponse | |
def self.wrap(app) | |
Rack::Builder.new(app) do | |
map('/ping') { run Proc.new { |env| [200, {'Content-Type' => 'text/plain'}, ['pong']] } } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment