fix(测试跟踪): 禅道图片同步后不显示
--bug=1020301 --user=陈建星 【测试跟踪】github #20125, 同步禅道缺陷后,缺陷内容中的图片无法展示 https://www.tapd.cn/55049933/s/1312407
This commit is contained in:
parent
951146df96
commit
efbbf010ea
|
@ -21,6 +21,7 @@ public class SessionFilter implements WebFilter {
|
||||||
private static final String[] TO_SUB_SERVICE = new String[]{"/license", "/system", "/resource", "/sso/callback/logout", "/sso/callback/cas/logout"};
|
private static final String[] TO_SUB_SERVICE = new String[]{"/license", "/system", "/resource", "/sso/callback/logout", "/sso/callback/cas/logout"};
|
||||||
private static final String PERFORMANCE_DOWNLOAD_PREFIX = "/jmeter/";
|
private static final String PERFORMANCE_DOWNLOAD_PREFIX = "/jmeter/";
|
||||||
private static final String API_DOWNLOAD_PREFIX = "/api/jmeter/";
|
private static final String API_DOWNLOAD_PREFIX = "/api/jmeter/";
|
||||||
|
private static final String TRACK_IMAGE_PREFIX = "/resource/md/get/url";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DiscoveryClient discoveryClient;
|
private DiscoveryClient discoveryClient;
|
||||||
|
@ -36,15 +37,15 @@ public class SessionFilter implements WebFilter {
|
||||||
if (path.startsWith("/css") || path.startsWith("/js")) {
|
if (path.startsWith("/css") || path.startsWith("/js")) {
|
||||||
for (String prefix : PREFIX) {
|
for (String prefix : PREFIX) {
|
||||||
if (path.contains(prefix)) {
|
if (path.contains(prefix)) {
|
||||||
ServerWebExchangeUtils.addOriginalRequestUrl(exchange, req.getURI());
|
return addPrefix(prefix, exchange, chain);
|
||||||
String newPath = prefix + path;
|
|
||||||
ServerHttpRequest request = req.mutate().path(newPath).build();
|
|
||||||
exchange.getAttributes().put(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR, request.getURI());
|
|
||||||
return chain.filter(exchange.mutate().request(request).build());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path.startsWith(TRACK_IMAGE_PREFIX)) {
|
||||||
|
return addPrefix("/track", exchange, chain);
|
||||||
|
}
|
||||||
|
|
||||||
// 有些url直接转到 sub-service
|
// 有些url直接转到 sub-service
|
||||||
for (String prefix : TO_SUB_SERVICE) {
|
for (String prefix : TO_SUB_SERVICE) {
|
||||||
if (path.startsWith(prefix)) {
|
if (path.startsWith(prefix)) {
|
||||||
|
@ -53,31 +54,29 @@ public class SessionFilter implements WebFilter {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
String service = svc.get();
|
String service = svc.get();
|
||||||
ServerWebExchangeUtils.addOriginalRequestUrl(exchange, req.getURI());
|
return addPrefix("/" + service + "/", exchange, chain);
|
||||||
String newPath = "/" + service + "/" + path;
|
|
||||||
ServerHttpRequest request = req.mutate().path(newPath).build();
|
|
||||||
exchange.getAttributes().put(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR, request.getURI());
|
|
||||||
return chain.filter(exchange.mutate().request(request).build());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从当前站点下载资源
|
// 从当前站点下载资源
|
||||||
if (path.startsWith(PERFORMANCE_DOWNLOAD_PREFIX)) {
|
if (path.startsWith(PERFORMANCE_DOWNLOAD_PREFIX)) {
|
||||||
ServerWebExchangeUtils.addOriginalRequestUrl(exchange, req.getURI());
|
return addPrefix("/performance", exchange, chain);
|
||||||
String newPath = "/performance" + path;
|
|
||||||
ServerHttpRequest request = req.mutate().path(newPath).build();
|
|
||||||
exchange.getAttributes().put(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR, request.getURI());
|
|
||||||
return chain.filter(exchange.mutate().request(request).build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.startsWith(API_DOWNLOAD_PREFIX)) {
|
if (path.startsWith(API_DOWNLOAD_PREFIX)) {
|
||||||
ServerWebExchangeUtils.addOriginalRequestUrl(exchange, req.getURI());
|
return addPrefix("/api", exchange, chain);
|
||||||
String newPath = "/api" + path;
|
|
||||||
ServerHttpRequest request = req.mutate().path(newPath).build();
|
|
||||||
exchange.getAttributes().put(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR, request.getURI());
|
|
||||||
return chain.filter(exchange.mutate().request(request).build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Mono<Void> addPrefix(String prefix, final ServerWebExchange exchange, final WebFilterChain chain) {
|
||||||
|
ServerHttpRequest req = exchange.getRequest();
|
||||||
|
String path = req.getURI().getRawPath();
|
||||||
|
ServerWebExchangeUtils.addOriginalRequestUrl(exchange, req.getURI());
|
||||||
|
String newPath = prefix + path;
|
||||||
|
ServerHttpRequest request = req.mutate().path(newPath).build();
|
||||||
|
exchange.getAttributes().put(ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR, request.getURI());
|
||||||
|
return chain.filter(exchange.mutate().request(request).build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue