mirror of
https://github.com/alibaba/higress.git
synced 2026-05-29 07:07:37 +08:00
fix: 🐛 [frontend-gray] 修复 请求非首页资源时候,路由配置 (#1353)
This commit is contained in:
@@ -68,15 +68,16 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, grayConfig config.GrayConfig,
|
|||||||
|
|
||||||
// 如果没有配置比例,则进行灰度规则匹配
|
// 如果没有配置比例,则进行灰度规则匹配
|
||||||
if isPageRequest {
|
if isPageRequest {
|
||||||
log.Infof("grayConfig.TotalGrayWeight==== %v", grayConfig.TotalGrayWeight)
|
|
||||||
if grayConfig.TotalGrayWeight > 0 {
|
if grayConfig.TotalGrayWeight > 0 {
|
||||||
|
log.Infof("grayConfig.TotalGrayWeight: %v", grayConfig.TotalGrayWeight)
|
||||||
deployment = util.FilterGrayWeight(&grayConfig, preVersion, preUniqueClientId, uniqueClientId)
|
deployment = util.FilterGrayWeight(&grayConfig, preVersion, preUniqueClientId, uniqueClientId)
|
||||||
} else {
|
} else {
|
||||||
deployment = util.FilterGrayRule(&grayConfig, grayKeyValue)
|
deployment = util.FilterGrayRule(&grayConfig, grayKeyValue)
|
||||||
}
|
}
|
||||||
log.Infof("index deployment: %v, path: %v, backend: %v, xPreHigressVersion: %s,%s", deployment, path, deployment.BackendVersion, preVersion, preUniqueClientId)
|
log.Infof("index deployment: %v, path: %v, backend: %v, xPreHigressVersion: %s,%s", deployment, path, deployment.BackendVersion, preVersion, preUniqueClientId)
|
||||||
} else {
|
} else {
|
||||||
deployment = util.GetVersion(grayConfig, deployment, preVersion, isPageRequest)
|
grayDeployment := util.FilterGrayRule(&grayConfig, grayKeyValue)
|
||||||
|
deployment = util.GetVersion(grayConfig, grayDeployment, preVersion, isPageRequest)
|
||||||
}
|
}
|
||||||
proxywasm.AddHttpRequestHeader(config.XHigressTag, deployment.Version)
|
proxywasm.AddHttpRequestHeader(config.XHigressTag, deployment.Version)
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ func GetVersion(grayConfig config.GrayConfig, deployment *config.Deployment, xPr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return grayConfig.BaseDeployment
|
return deployment
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从cookie中解析出灰度信息
|
// 从cookie中解析出灰度信息
|
||||||
@@ -294,12 +294,12 @@ func InjectContent(originalHtml string, injectionConfig *config.Injection) strin
|
|||||||
|
|
||||||
modifiedHtml := sb.String()
|
modifiedHtml := sb.String()
|
||||||
|
|
||||||
// 注入到头部
|
// 注入到头部
|
||||||
modifiedHtml = strings.ReplaceAll(modifiedHtml, "</head>", headInjection + "\n</head>")
|
modifiedHtml = strings.ReplaceAll(modifiedHtml, "</head>", headInjection+"\n</head>")
|
||||||
// 注入到body头
|
// 注入到body头
|
||||||
modifiedHtml = strings.ReplaceAll(modifiedHtml, "<body>", "<body>\n" + bodyFirstInjection)
|
modifiedHtml = strings.ReplaceAll(modifiedHtml, "<body>", "<body>\n"+bodyFirstInjection)
|
||||||
// 注入到body尾
|
// 注入到body尾
|
||||||
modifiedHtml = strings.ReplaceAll(modifiedHtml, "</body>", bodyLastInjection + "\n</body>")
|
modifiedHtml = strings.ReplaceAll(modifiedHtml, "</body>", bodyLastInjection+"\n</body>")
|
||||||
|
|
||||||
return modifiedHtml
|
return modifiedHtml
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user