Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use path_info instead of path to match /_ping

path includes script_name which means that if an app's root is example.com/app, example.com/app/_ping won't work by default. Checking against path_info excludes the script name which means that it will check /_ping against the app root instead of the domain.

So if the app is hosted at app.example.com, app.example.com/_ping will work by default, and if the app is hosted at example.com/app, example.com/app/_ping will work by default as well.
  • Loading branch information...
commit ad8f99f0f3f0e5efa77bb017aaeb967217cb5f40 1 parent b023263
@adamcrown adamcrown authored
Showing with 15 additions and 1 deletion.
  1. +1 −1  lib/pinglish.rb
  2. +14 −0 test/pinglish_test.rb
View
2  lib/pinglish.rb
@@ -39,7 +39,7 @@ def initialize(app, options = nil, &block)
def call(env)
request = Rack::Request.new env
- return @app.call env unless request.path == @path
+ return @app.call env unless request.path_info == @path
groups = [].map(&:to_s) # FIX
View
14 test/pinglish_test.rb
@@ -138,6 +138,20 @@ def test_with_check_that_times_out
assert_equal ["long"], json["timeouts"]
end
+ def test_with_script_name
+ app = build_app
+
+ session = Rack::Test::Session.new(app)
+ session.get "/_ping", {}, "SCRIPT_NAME" => "/myapp"
+ assert_equal 200, session.last_response.status
+ assert_equal "application/json; charset=UTF-8",
+ session.last_response.content_type
+
+ json = JSON.load(session.last_response.body)
+ assert json.key?("now")
+ assert_equal "ok", json["status"]
+ end
+
def test_with_custom_path
app = build_app(:path => "/_piiiiing")
Please sign in to comment.
Something went wrong with that request. Please try again.