Ruby,发布和重定向

发布于 2024-08-26 12:05:47 字数 332 浏览 4 评论 0原文

我遇到这样的情况:

  • 用户在 '/pay' 中提交带有 action='/pay' 的表单
  • 我必须添加一些附加参数并将发布请求发送到 www. paymentprovider.com/new_ payment问题

是我想将用户发布并重定向(同时)到这个新网站www. paymentprovider.com/new_ payment。目前我正在使用

Net::HTTP.post_form 

你知道有什么方法可以实现这一目标吗?

I have situation like this:

  • user submits form with action='/pay'
  • in '/pay' I have to add some additional parameters and send post request to www.paymentprovider.com/new_payment

The problem is that I want to post and redirect (at the same time) user to this new website www.paymentprovider.com/new_payment. Currently I am using

Net::HTTP.post_form 

Do you know any ways to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆追雨的时光 2024-09-02 12:05:47

您无法在不中断互联网的情况下进行发布和重定向。 :)

如果您想使用此工作流程,您将需要代理该请求。

举个例子:

  1. 用户提交到 /pay
  2. 您获取这些参数并向 /new_ payment 发出请求
  3. 您可以从 /new_ payment 获取结果并将它们发送回 /pay 中的请求

由于这一切都发生在本地,因此上面的选项似乎成为废物。如果 /pay 只是缺少一些参数和信息,您可以简单地在您看来提供它们吗?这样,您就可以将 /pay 和 /new_ payment 回发到同一位置,并使用两个单独的视图来处理初始获取请求。

You cannot do a post and redirect without breaking the internet. :)

If you want to use this workflow, you will need to proxy the request.

As an example:

  1. User submits to /pay
  2. You grab those paramaters and make a request to /new_payment
  3. You can grab the results from /new_payment and send them back to the request in /pay

Since this is all happening locally, the option above would seem to be a waste. If /pay is simply missing some parameters and info could you simply supply them in your view? This way you could have both /pay and /new_payment postback to the same location and use two separate views to handle the initial get request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文