Created
May 17, 2013 12:27
-
-
Save morr/5598700 to your computer and use it in GitHub Desktop.
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
| # 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