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

当您转到http.Redirect的golang文档时,您实际上可以单击蓝色 Headers :

func重定向

它将带您进入源代码清单,这是不言自明的:

// Redirect replies to the request with a redirect to url,

// which may be a path relative to the request path.

func Redirect(w ResponseWriter, r *Request, urlStr string, code int) {

if u, err := url.Parse(urlStr); err == nil {

// If url was relative, make absolute by

// combining with request path.

// The browser would probably do this for us,

// but doing it ourselves is more reliable.

// NOTE(rsc): RFC 2616 says that the Location

// line must be an absolute URI, like

// "http://www.google.com/redirect/",

// not a path like "/redirect/".

// Unfortunately, we don't know what to

// put in the host name section to get the

// client to connect to us ag

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值