@Bean public Feign.Builder feignBuilder(@Autowired List<RequestInterceptor> interceptors) { return Feign.builder() .requestInterceptors(interceptors); }
/** * The generalized version of the method that allows more in-depth customizations via * {@link RequestInterceptor}s. * * @param endpoint * URL of Marathon * @param interceptors optional request interceptors * @return Marathon client */ public static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) { Builder b = Feign.builder() .encoder(new GsonEncoder(ModelUtils.GSON)) .decoder(new GsonDecoder(ModelUtils.GSON)) .errorDecoder(new MarathonErrorDecoder()); if (interceptors != null) b.requestInterceptors(asList(interceptors)); String debugOutput = System.getenv(DEBUG_JSON_OUTPUT); if ("System.out".equals(debugOutput)) { System.setProperty("org.slf4j.simpleLogger.logFile", "System.out"); System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug"); b.logger(new Slf4jLogger()).logLevel(Logger.Level.FULL); } else if (debugOutput != null) { b.logger(new Logger.JavaLogger().appendToFile(debugOutput)).logLevel(Logger.Level.FULL); } b.requestInterceptor(new MarathonHeadersInterceptor()); return b.target(Marathon.class, endpoint); }
/** * The generalized version of the method that allows more in-depth customizations via * {@link RequestInterceptor}s. * * @param endpoint * URL of Marathon * @param interceptors * A collection of {@link RequestInterceptor} to use * @return * A {@link Marathon} instance using the given interceptors and endpoint URL. */ public static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) { Builder b = Feign.builder() .encoder(new GsonEncoder(ModelUtils.GSON)) .decoder(new GsonDecoder(ModelUtils.GSON)) .errorDecoder(new MarathonErrorDecoder()); if (interceptors != null) b.requestInterceptors(asList(interceptors)); String debugOutput = System.getenv(DEBUG_JSON_OUTPUT); if ("System.out".equals(debugOutput)) { System.setProperty("org.slf4j.simpleLogger.logFile", "System.out"); System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug"); b.logger(new Slf4jLogger()).logLevel(Logger.Level.FULL); } else if (debugOutput != null) { b.logger(new Logger.JavaLogger().appendToFile(debugOutput)).logLevel(Logger.Level.FULL); } b.requestInterceptor(new MarathonHeadersInterceptor()); return b.target(Marathon.class, endpoint); }
Feign.Builder builder = newFeignClientBuilder(); builder.client(client); builder.requestInterceptors(requestInterceptors); builder.errorDecoder(errorDecoder); if (decode404) {
protected void configureUsingConfiguration(FeignContext context, Feign.Builder builder) { Logger.Level level = getOptional(context, Logger.Level.class); if (level != null) { builder.logLevel(level); } Retryer retryer = getOptional(context, Retryer.class); if (retryer != null) { builder.retryer(retryer); } ErrorDecoder errorDecoder = getOptional(context, ErrorDecoder.class); if (errorDecoder != null) { builder.errorDecoder(errorDecoder); } Request.Options options = getOptional(context, Request.Options.class); if (options != null) { builder.options(options); } Map<String, RequestInterceptor> requestInterceptors = context.getInstances( this.contextId, RequestInterceptor.class); if (requestInterceptors != null) { builder.requestInterceptors(requestInterceptors.values()); } if (decode404) { builder.decode404(); } }
protected void configureUsingConfiguration(FeignContext context, Feign.Builder builder) { Logger.Level level = getOptional(context, Logger.Level.class); if (level != null) { builder.logLevel(level); } Retryer retryer = getOptional(context, Retryer.class); if (retryer != null) { builder.retryer(retryer); } ErrorDecoder errorDecoder = getOptional(context, ErrorDecoder.class); if (errorDecoder != null) { builder.errorDecoder(errorDecoder); } Request.Options options = getOptional(context, Request.Options.class); if (options != null) { builder.options(options); } Map<String, RequestInterceptor> requestInterceptors = context.getInstances( this.contextId, RequestInterceptor.class); if (requestInterceptors != null) { builder.requestInterceptors(requestInterceptors.values()); } if (decode404) { builder.decode404(); } }
/** * The generalized version of the method that allows more in-depth customizations via * {@link RequestInterceptor}s. * * @param endpoint URL for Chronos API */ public static Chronos getInstance(String endpoint, RequestInterceptor... interceptors) { Builder b = Feign.builder() .encoder(new GsonEncoder(AbstractModel.GSON)) .decoder(new MultiDecoder()) .errorDecoder(new ChronosErrorDecoder()); if (interceptors != null) { b.requestInterceptors(asList(interceptors)); } b.requestInterceptor(new ChronosHeadersInterceptor()); return b.target(Chronos.class, endpoint); }
@Override public Builder requestInterceptors(Iterable<RequestInterceptor> requestInterceptors) { return (Builder) super.requestInterceptors(requestInterceptors); } }