You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
유레카에 등록된 앱중 metadata.profile 이 자신의 spring.profiles.active 와 동일한 것을 선택하여 필터링한다.
FeignRequestInterceptor.java
private void updateRibbonFilterContextHolder() {
ApplicationContext applicationContext = ApplicationContextRegistry.getApplicationContext();
Environment environment = applicationContext.getBean(Environment.class);
String[] activeProfiles = environment.getActiveProfiles();
//필터 초기화
RibbonFilterContextHolder.getCurrentContext().remove("profile");
String[] list = new String[]{"local", "dev", "stg", "prod"};
List<String> filterProfiles = Arrays.asList(list);
//자신의 액티브 프로파일을 필터에 추가
for (String activeProfile : activeProfiles) {
if (filterProfiles.contains(activeProfile)) {
RibbonFilterContextHolder.getCurrentContext()
.add("profile", activeProfile);
}
}
}
토큰 전달
TenantAwareFilter 에서 받은 토큰이 있다면, Feign 클라이언트 호출시 그대로 전달한다.
FeignRequestInterceptor.java
public void apply(RequestTemplate template) {
.
.
//오리지널 요청에 토큰이 있다면 토큰 전달
String token = TokenContext.getThreadLocalInstance().getToken();
if (!StringUtils.isEmpty(token)) {
template.header("access_token", token);
}
}
빈 등록
FeignRequestInterceptor 를 Metaworks4WebConfig 에 빈 등록.
@Bean
public FeignRequestInterceptor feignRequestInterceptor() {
return new FeignRequestInterceptor();
}
The text was updated successfully, but these errors were encountered:
feign 클라이언트 호출시 동작
Profile 필터
유레카에 등록된 앱중 metadata.profile 이 자신의 spring.profiles.active 와 동일한 것을 선택하여 필터링한다.
FeignRequestInterceptor.java
토큰 전달
TenantAwareFilter
에서 받은 토큰이 있다면, Feign 클라이언트 호출시 그대로 전달한다.FeignRequestInterceptor.java
빈 등록
FeignRequestInterceptor
를Metaworks4WebConfig
에 빈 등록.The text was updated successfully, but these errors were encountered: