Skip to content

Instantly share code, notes, and snippets.

@tobiashm
Created July 24, 2013 11:20
Show Gist options
  • Save tobiashm/6069741 to your computer and use it in GitHub Desktop.
Save tobiashm/6069741 to your computer and use it in GitHub Desktop.
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
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