Skip to content

Instantly share code, notes, and snippets.

@morr
Created May 17, 2013 12:27
Show Gist options
  • Select an option

  • Save morr/5598700 to your computer and use it in GitHub Desktop.

Select an option

Save morr/5598700 to your computer and use it in GitHub Desktop.
# encoding: utf-8
class ProxyTest
SuccessConfirmationMessage = "test_passed"
TestPage = "/proxy_test"
WhatIsMyIpPage = "/what_is_my_ip"
def initialize(app)
@app = app
end
def call(env)
if env['PATH_INFO'] == TestPage # тест прокси
data = env.select {|k,v| k =~ /^[A-Z_]+$/ && k != 'SERVER_ADDR' && k != 'HTTP_COOKIE' }.map {|k,v| v }.join " | "
[200, {'Content-Type' => 'text/plain'}, [
"#{data} #{SuccessConfirmationMessage}"
]]
elsif env['PATH_INFO'] == WhatIsMyIpPage # выдача ip
[200,
{'Content-Type' => 'text/plain'},
[
env['REMOTE_ADDR']
]
]
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