springcloud使用feign下载

2019-06-25  本文已影响0人  ydd7z

springcloud版本Finchley.RELEASE
springboot版本2.0.8.RELEASE

public interface DownloadService {
    @RequestLine("GET")
    Response downloadPdf(URI uri);
    
    @Component
    @Import(FeignClientsConfiguration.class)
    class DownloadServiceImpl implements DownloadService {
        private DownloadService downloadService;
        
        @Autowired
        public DownloadServiceImpl(Decoder decoder, Encoder encoder) {
            downloadService = Feign.builder()
                    .encoder(encoder).decoder(decoder).target(Target.EmptyTarget.create(DownloadService.class));
        }
        
        @Override
        public Response downloadPdf(URI uri) {
            return downloadService.downloadPdf(uri);
        }
        
    }

}

上一篇 下一篇

猜你喜欢

热点阅读