I created a library and would like to ask if it can be merged into Spring? I only added the production code in this PR to show what would need to be changed. The test cases are still in the library.

Would you like me to continue work on this?


Dynamically create Spring RestTemplate (proxy class) client from annotated interface.

Given MyApiInterface is a Spring-annotated Java interface.

final MyApiInterface myClient = SpringRestTemplateClientBuilder
  .create(MyApiInterface.class)
  .setUrl(this.getMockUrl())
  .setRestTemplate(restTemplate)         // Optional
  .setHeader("header-name", "the value") // Optional
  .setHeaders(HttpHeaders)               // Optional
  .build();

Here myClient is a dynamically created Java Proxy object.

final ResponseEntity<MyDTO> response = myClient.getMyDto();

The method invocation (getMyDto()) on that object (myClient) will be translated to a HTTP request using the annotations of that method in that interface. And response will be the result of that HTTP request.

Comment From: JWThewes

Isn't this what feign is supposed to do? I dont't see a big difference here?

Comment From: tomasbjerre

The difference is the dependencies needed. It is nice not to have Feign and all its transitives on classpath. My library has only one dependency, and it is on spring-web.

Comment From: bclozel

Sorry we didn't get to this earlier, but we now have dedicated support for this in Spring Framework. I'm closing this issue as a result.

Thanks!