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

The following examples show how to use org.springframework.cloud.openfeign.support.SpringDecoder. These examples are extracted from open source projects. 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 Project: feign-form   Source File: DownloadClient.java    License: 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 2
Source Project: XS2A-Sandbox   Source File: FeignConfig.java    License: 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 3
@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 4
Source Project: zuihou-admin-cloud   Source File: CorsConfiguration.java    License: Apache License 2.0 5 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 5
Source Project: spring-cloud-in-action   Source File: ReservationService.java    License: 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 Project: gateway   Source File: FeignConfig.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Bean
public Decoder feignDecoder() {
    return new ResponseEntityDecoder(new SpringDecoder(feignHttpMessageConverter()));
}
 
Example 7
@Bean
@ConditionalOnMissingBean
public Decoder feignDecoder(List<ApiResultHandler> apiResultHandlers) {
    return new ApiResultDecoder(new ResponseEntityDecoder(new SpringDecoder(this.messageConverters)),
        apiResultHandlers);
}
 
Example 8
public SummerWrappedApiResultHandler(Class<? extends ApiResultWrapper> apiResultType, SpringDecoder springDecoder) {
    this.apiResultType = apiResultType;
    this.springDecoder = springDecoder;
}
 
Example 9
@Bean
@ConditionalOnMissingBean
public Decoder feignDecoder() {
	return new OptionalDecoder(
			new ResponseEntityDecoder(new SpringDecoder(this.messageConverters)));
}
 
Example 10
@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));
}