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

The following examples show how to use org.springframework.cloud.openfeign.support.SpringEncoder. 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: TppUiBeFeignConfiguration.java    From XS2A-Sandbox with Apache License 2.0 5 votes vote down vote up
@Bean
public Encoder feignEncoder() {
    objectMapper.addMixIn(ScaUserDataTO.class, ScaUserDataMixedIn.class)
        .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(objectMapper);
    ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
    return new SpringEncoder(objectFactory);
}
 
Example #2
Source File: FeignClientsConfiguration.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
private Encoder springEncoder(ObjectProvider<AbstractFormWriter> formWriterProvider) {
	AbstractFormWriter formWriter = formWriterProvider.getIfAvailable();

	if (formWriter != null) {
		return new SpringEncoder(new SpringPojoFormEncoder(formWriter),
				this.messageConverters);
	}
	else {
		return new SpringEncoder(new SpringFormEncoder(), this.messageConverters);
	}
}
 
Example #3
Source File: ProtobufNotInClasspathTest.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncodeWhenProtobufNotInClasspath() {
	ObjectFactory<HttpMessageConverters> converters = new ObjectFactory<HttpMessageConverters>() {
		@Override
		public HttpMessageConverters getObject() throws BeansException {
			return new HttpMessageConverters(new StringHttpMessageConverter());
		}
	};
	RequestTemplate requestTemplate = new RequestTemplate();
	requestTemplate.method(POST);
	new SpringEncoder(converters).encode("a=b", String.class, requestTemplate);
}
 
Example #4
Source File: ProtobufSpringEncoderTest.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
private SpringEncoder newEncoder() {
	ObjectFactory<HttpMessageConverters> converters = new ObjectFactory<HttpMessageConverters>() {
		@Override
		public HttpMessageConverters getObject() throws BeansException {
			return new HttpMessageConverters(new ProtobufHttpMessageConverter());
		}
	};
	return new SpringEncoder(converters);
}
 
Example #5
Source File: FeignAutoConfiguration.java    From open-cloud with MIT License 4 votes vote down vote up
@Bean
public Encoder feignFormEncoder(ObjectFactory<HttpMessageConverters> messageConverters) {
    Encoder encoder = new FeignSpringFormEncoder(new SpringEncoder(messageConverters));
    log.info("FeignSpringFormEncoder [{}]", encoder);
    return encoder;
}
 
Example #6
Source File: EnableFeignClientsTests.java    From spring-cloud-openfeign with Apache License 2.0 4 votes vote down vote up
@Test
public void encoderDefaultCorrect() {
	SpringEncoder.class.cast(this.context.getBeansOfType(Encoder.class).get(0));
}
 
Example #7
Source File: FeignMultipartSupportConfig.java    From agile-service-old with Apache License 2.0 4 votes vote down vote up
@Bean
public Encoder feignFormEncoder() {
    return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
 
Example #8
Source File: Client.java    From feign-form with Apache License 2.0 4 votes vote down vote up
@Bean
public Encoder feignEncoder () {
  return new SpringFormEncoder(new SpringEncoder(messageConverters));
}