流殃的博客

| Comments

调用

@FeignClient
public interface FeignDemo{
     @requestMapping("/test)
     public String test();
}

拦截器

很简单的使用方法,直接去实现RequestInterceptor接口就可以了

@Slf4j
@Component
public class MyFeignInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();

        log.info("===request: {}", template.url());
        template.header("aaaa", "bbbb");
    }
}

Comments

评论