title: Java Spring - intercepting execution of a REST Client (Hystrix Feign)
body: <p>I have a REST client interface like this:</p>
  
  <pre><code>public interface NameSearchClient {
      @RequestLine("POST")
      @Headers("Content-Type: application/json")
      SearchResponse searchByName(NameSearchRequest request);
  
  }
  </code></pre>
  
  <p>It gets implemented and set-up in a factory class like this:</p>
  
  <pre><code>@Component
  public class NameClientFactory {
      public &lt;T&gt; T createFeignClient(Class&lt;T&gt; clientClass, String apiUrl) {
          return Feign.builder()
                  .encoder(new GsonEncoder())
                  .decoder(new GsonDecoder())
                  .target(clientClass, apiUrl);
      }
  }
  </code></pre>
  
  <p>I was wondering if it's possible to write an Aspect annotation that upon every call made by that client, executes some action (another HTTP call in my case) and adds a new header to the request? Is AspectJ the right tool for that?</p>