Redirect without changing the request
Hello I would like to implement the following functionality with RoR.
Site B is requesting something for site A:
http://sitea.com?test=开发者_StackOverflow1&test2=2&test3=3 [From SiteB to SiteA]
Site A pass the request untouched to site C:
http://sitec.com?test=1&test2=2&test3=3 [From SiteA to SiteC]
Site C returns results to Site A which returns results to Site B.
Is that possible with Rails?
Something like a proxy?
EDIT: I am interested for the controller of site A, the site in the middle!
.. for simple GET requests, you could do:
Gemfile:
...
gem 'httparty'
...
config/routes.rb:
...
match '*p', :to => 'forward#index'
...
app/controllers/forward_controller.rb:
Class ForwardController < ApplicationController
def index
render :text => HTTParty.get(request.url).body
end
end
精彩评论