title: What is the correct achitecture using RestTemplate and RestTemplateCustomizer with multiple services?
body: <p>how are you? I hope you are doing awesome.</p>
  
  <p>I'm creating a new Spring Boot app for my company and for this specific app I need to communicate with different micro-services, some with different configurations. For example: Some services require different headers.</p>
  
  <p>Im not quite sure how to do it in a correct elegant way. I was taking the approach to create "Clients" as @Component that communicate with the micro-services using a rest template created like this:</p>
  
  <pre><code>@Component
  public class ShifuClient {
  
      private final RestTemplate restTemplate;
  
      private static final String HOST = "http://example.com/service/";
  
      @Autowired
      public ShifuClient(RestTemplateBuilder builder) {
          this.restTemplate = builder.build();
      }
  
      public ShifuDto getShifuTemplate(Locale locale) {
          return this.restTemplate.getForObject(HOST+ "?locale={locale}", ShifuDto.class, locale.toString());
      }
  }
  </code></pre>
  
  <p>I also have a bean for an application wide customizer that adds common headers and logs the request.</p>
  
  <pre><code>/**
   * Customizes the creation of the {@link RestTemplate}
   * used for connecting with other services.
   * This configuration is application wide and applies to every request made with {@link RestTemplate}.
   */
  public class ApplicationWideRestTemplateCustomizer implements    RestTemplateCustomizer {
  
      @Override
      public void customize(RestTemplate restTemplate) {
          restTemplate.getInterceptors().add(new     AddHeadersRequestInterceptor());
          restTemplate.getInterceptors().add(new LogRequestInterceptor());
      }
  }
  </code></pre>
  
  <p>So the problem is now that I want a specific header configuration + the common header configuration for the resttemplate of different clients. I can also see that a pattern will repeat, maybe I will need an abstract "Client" class. </p>
  
  <p>How do you think I must proceed in the design to make this elegant and to make this work as intended?</p>
  
  <p>Thank you very much for your help.</p>