org.springframework.cloud.openfeign.support.SpringDecoder Java Examples

The following examples show how to use org.springframework.cloud.openfeign.support.SpringDecoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CorsConfiguration.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 升级版本后, 不加这个 gateway 使用feign会报错,不知道什么原因
 *
 * @return
 */
@Bean
public Decoder feignFormDecoder() {
    List<HttpMessageConverter<?>> converters = new RestTemplate().getMessageConverters();
    ObjectFactory<HttpMessageConverters> factory = () -> new HttpMessageConverters(converters);
    return new ResponseEntityDecoder(new SpringDecoder(factory));
}
 
Example #2
Source File: DownloadClient.java    From feign-form with Apache License 2.0 6 votes vote down vote up
@Bean
public Decoder feignDecoder () {
  val springConverters = messageConverters.getObject().getConverters();
  val decoderConverters = new ArrayList<HttpMessageConverter<?>>(springConverters.size() + 1);

  decoderConverters.addAll(springConverters);
  decoderConverters.add(new SpringManyMultipartFilesReader(4096));

  val httpMessageConverters = new HttpMessageConverters(decoderConverters);

  return new SpringDecoder(new ObjectFactory<HttpMessageConverters>() {

    @Override
    public HttpMessageConverters getObject () {
        return httpMessageConverters;
    }
  });
}
 
Example #3
Source File: FeignConfig.java    From XS2A-Sandbox with Apache License 2.0 5 votes vote down vote up
@Bean
public Decoder feignDecoder() {
	ObjectMapper objectMapper = new ObjectMapper();
	objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
	objectMapper.registerModule(new JavaTimeModule());
	HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(objectMapper);
	ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
	return new ResponseEntityDecoder(new SpringDecoder(objectFactory));
}
 
Example #4
Source File: OpenFeignAutoConfiguration.java    From summerframework with Apache License 2.0 5 votes vote down vote up
@Bean
public SummerWrappedApiResultHandler
    summer2WrappedApiResultHandler(ApiResultTransformer<? extends ApiResultWrapper> apiResultTransformer) {
    if (apiResultTransformer.getType().isInterface()) {
        throw new IllegalArgumentException(
            "ApiResultTransformer.getType() should be type of any ***class*** that implements ApiResultWrapper");
    }
    return new SummerWrappedApiResultHandler(apiResultTransformer.getType(),
        new SpringDecoder(this.messageConverters));
}
 
Example #5
Source File: ReservationService.java    From spring-cloud-in-action with MIT License 5 votes vote down vote up
@Bean
public Decoder feignDecoder() {
  ObjectMapper objectMapper = new ObjectMapper()
      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
      .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
      .registerModule(new Jackson2HalModule());

  MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
  jacksonConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
  jacksonConverter.setObjectMapper(objectMapper);

  ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
  return new ResponseEntityDecoder(new SpringDecoder(objectFactory));
}
 
Example #6
Source File: FeignConfig.java    From gateway with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public Decoder feignDecoder() {
    return new ResponseEntityDecoder(new SpringDecoder(feignHttpMessageConverter()));
}
 
Example #7
Source File: OpenFeignAutoConfiguration.java    From summerframework with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Decoder feignDecoder(List<ApiResultHandler> apiResultHandlers) {
    return new ApiResultDecoder(new ResponseEntityDecoder(new SpringDecoder(this.messageConverters)),
        apiResultHandlers);
}
 
Example #8
Source File: SummerWrappedApiResultHandler.java    From summerframework with Apache License 2.0 4 votes vote down vote up
public SummerWrappedApiResultHandler(Class<? extends ApiResultWrapper> apiResultType, SpringDecoder springDecoder) {
    this.apiResultType = apiResultType;
    this.springDecoder = springDecoder;
}
 
Example #9
Source File: FeignClientsConfiguration.java    From spring-cloud-openfeign with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Decoder feignDecoder() {
	return new OptionalDecoder(
			new ResponseEntityDecoder(new SpringDecoder(this.messageConverters)));
}
 
Example #10
Source File: SpringCloudConfiguration.java    From ByteJTA with GNU Lesser General Public License v3.0 4 votes vote down vote up
@org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean(feign.codec.Decoder.class)
@org.springframework.context.annotation.Bean
public feign.codec.Decoder feignDecoder(@Autowired ObjectFactory<HttpMessageConverters> messageConverters) {
	return new ResponseEntityDecoder(new SpringDecoder(messageConverters));
}