示例#1
0
func (preserve filter) Request(ctx filters.FilterContext) {
	u, err := url.Parse(ctx.BackendUrl())
	if err != nil {
		log.Error("failed to parse backend host in preserveHost filter", err)
		return
	}

	if preserve && ctx.OutgoingHost() == u.Host {
		ctx.SetOutgoingHost(ctx.Request().Host)
	} else if !preserve && ctx.OutgoingHost() == ctx.Request().Host {
		ctx.SetOutgoingHost(u.Host)
	}
}