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

The following examples show how to use org.springframework.cloud.openfeign.support.ResponseEntityDecoder. 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
private AbstractSimulatedDevice createDdiDevice(final String id, final String tenant, final int pollDelaySec,
        final URL baseEndpoint, final String gatewayToken) {

    final ObjectMapper mapper = new ObjectMapper()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .registerModule(new Jackson2HalModule());

    final RootControllerResourceClient controllerResource = Feign.builder()
            .requestInterceptor(new GatewayTokenInterceptor(gatewayToken))
            .contract(new IgnoreMultipleConsumersProducersSpringMvcContract()).logLevel(Level.HEADERS)
            .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper))).encoder(new JacksonEncoder())
            .logger(new Slf4jLogger()).decode404()
            .target(RootControllerResourceClient.class, baseEndpoint.toString());

    return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, deviceUpdater, gatewayToken);
}
 
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
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 4
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 5
Source Project: hawkbit-examples   Source File: Application.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private static MgmtSoftwareModuleClientResource uploadSoftwareModule(
        final ClientConfigurationProperties configuration) {
    final ObjectMapper mapper = new ObjectMapper()
            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
            .registerModule(new Jackson2HalModule());
    return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract()).decode404()
            .requestInterceptor(
                    new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword()))
            .logger(new Slf4jLogger()).encoder(new FeignMultipartEncoder())
            .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper)))
            .target(MgmtSoftwareModuleClientResource.class, configuration.getUrl());
}
 
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
@Bean
@ConditionalOnMissingBean
public Decoder feignDecoder() {
	return new OptionalDecoder(
			new ResponseEntityDecoder(new SpringDecoder(this.messageConverters)));
}
 
Example 9
@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));
}