dongqun5769 2012-08-13 00:41
浏览 134
已采纳

如何在golang中创建绝对路径http重定向

I was reading the source code goto, and I found the code below in goto/talk/0/main.go:

http.Redirect(w, r, url, http.StatusFound)

According to the context, url was an absolute path, and an absolute path redirect was expected. But as the golang/http/redirect mentioned:

Redirect replies to the request with a redirect to url, which may be a path relative to the request path.

It results as a relative path redirect. I don't know if http.Redirect did an absolute path redirect before, but it doesn't nowadays.

So how can I make an absolute path redirect in golang? I searched the Internet, but found nothing,can anyone help me? Thanks in advance.

  • 写回答

2条回答 默认 最新

  • douxin1163 2012-08-13 04:34
    关注

    I finally found that to perform an absolute path redirect, the url must be a complete url, such as http://www.stackoverflow.com or https://github.com, but not www.stackoverflow.com.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部