mirror of https://github.com/jeecgboot/jeecg-boot
feign 动态创建client,拦截器执行多次 #2275
parent
d16520cc59
commit
766c48bdbf
|
@ -35,11 +35,7 @@ public class JeecgFeignService implements IJeecgFeignService {
|
||||||
.encoder(encoder)
|
.encoder(encoder)
|
||||||
.decoder(decoder)
|
.decoder(decoder)
|
||||||
.contract(contract);
|
.contract(contract);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T newInstance(Class<T> clientClass, String serviceName) {
|
|
||||||
builder.requestInterceptor(requestTemplate -> {
|
builder.requestInterceptor(requestTemplate -> {
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
if (null != attributes) {
|
if (null != attributes) {
|
||||||
|
@ -54,6 +50,11 @@ public class JeecgFeignService implements IJeecgFeignService {
|
||||||
requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, token);
|
requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T newInstance(Class<T> clientClass, String serviceName) {
|
||||||
return builder.target(clientClass, String.format("http://%s/", serviceName));
|
return builder.target(clientClass, String.format("http://%s/", serviceName));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue