GAE Go的HTTP POST链接

huangapple go评论89阅读模式
英文:

GAE Go http post link

问题

我在GAE上有一个用Go编写的Web应用程序,用于为用户执行一些计算。该网站通过简单的HTTP Post与服务器通信。我想让用户能够分享他们获得的结果的链接,而不需要在我的Go代码中进行太多更改。

有没有一种将HTTP Post消息编码为网站URL的方法,以便在应用引擎上执行,就像用户从网站发送了Post一样?

如何编写一个按钮的代码,将正确的链接复制到用户的剪贴板(注意,字段值可能在加载页面和用户想要链接之间发生变化,因此通过GAE解析器硬编码值将不起作用)。

英文:

I have a web app on GAE written in Go that performs some calculations for the user. The website communicates with the server through a simple HTTP Post. I want to let the user be able to share a link to the result they obtained without changing much in my Go code.

Is there some way to encode a HTTP Post message as a website url that would execute on the app engine as if the user sent the Post from the website?

How would the code for a button that would copy the proper link to user's clipboard (noting that the field values can change between page being loaded and user wanting the link, so hard-coding the values through GAE parser wouldn't work).

答案1

得分: 4

使用GET而不是POST。这就是GET的目的:它生成一个可书签的URL。

除非发送的数据包含机密信息或太大而无法放入GET参数中,否则应始终使用GET进行幂等操作。

英文:

Use a GET instead of a POST. That's the point of GET : it generates a bookmarkable URL.

GET should always be used for idempotent operations, unless the sent data contain secret information or are too large to be put into GET parameters.

答案2

得分: 0

如JB的回答中所述,您可以使用GET而不是post。
或者,您可以将POST数据存储在数据存储中,并为每个记录分配一个ID。然后,您可以生成一个带有该ID作为GET参数的URL。
当用户点击该链接时,您的应用程序会从数据存储中读取您的POST数据,并完成请求。

请查看此链接以将链接/文本复制到用户的剪贴板。

http://www.deluxeblogtips.com/2010/06/javascript-copy-to-clipboard.html

英文:

As in JB's answer you can use GET instead of post.
Or you can store the POST data in your datastore with an ID for each record. Then you can generated a url with that ID as a GET parameter.
When user clicks on that link your app reads your POST data from datastore, complete the request.

Check this link for copying link/text to users clipboard.

http://www.deluxeblogtips.com/2010/06/javascript-copy-to-clipboard.html

huangapple
  • 本文由 发表于 2011年10月22日 19:04:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/7859037.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定