开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜