开发者

Redirect without changing the request

开发者 https://www.devze.com 2023-03-26 04:40 出处:网络
Hello I would like to implement the following functionality with RoR. Site B is requesting something for site A:

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

精彩评论

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