Interceptor not getting called when zuul.routes configured in gateway
<p>When I configure zuul routes in bootstrap.properties, my <strong>TestHandlerInterceptor</strong> defined in gareway application is not getting invoked for all the request matching <strong>/registrations</strong> but it gets called for all other request  TestHandlerInterceptor.preHandle  is getting processed successfully </p>

<p><em>bootstrap.properties</em> </p>

<pre><code>zuul.routes.registration-service.path=**registrations**
zuul.routes.registration-service.service=registration-service
</code></pre>

<p>TestHandlerInterceptor.java</p>

<pre><code>public class TestHandlerInterceptor implements HandlerInterceptor {


 @Autowired
 AuthenticationService authenticationService;


 @Override
 public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {

    System.out.println(" ********* preHandle ********");
    boolean result = true;
    if(!authenticationService.isAuthenticated(httpServletRequest)){
        result = false;
        httpServletResponse.setStatus(401);
    }


    return result;
 }

 @Override
 public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {

 }

 @Override
 public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {

}
 }
</code></pre>

<p>GatewayApplication.java</p>

<pre><code>@EnableZuulProxy
@SpringBootApplication
@EnableDiscoveryClient
public class GatewayApplication{

 public static void main(String[] args) {
     SpringApplication.run(GatewayApplication.class, args);
 }

 @Bean
 public WebMvcConfigurerAdapter adapter() {
    return new WebMvcConfigurerAdapter() {
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
            registry.addInterceptor(new TestHandlerInterceptor());
            super.addInterceptors(registry);
        }
    };
 }
}


@RestController
class Orchestration {
 @LoadBalanced
 @Autowired
  private RestTemplate restTemplate ;

 @RequestMapping("/api/test")
 public @ResponseBody
 Collection&lt;Registration&gt; getRegistrations(){
   ResponseEntity&lt;Resources&lt;Client&gt;&gt; resourceResponseEntity =  this.restTemplate.exchange("http://registration-service/registrations", HttpMethod.GET,null, ptr);

 }

}
</code></pre>

<p>The TestHandlerInterceptor.preHandle executes for localhost:1122/api/test but its not getting called for localhost:1122/registrations</p>

<p>I am trying to add a AuthenticationService in my interceptor which will perform all stateless Authentication(using api keys) before any of the sub resource is requested.</p>

<p>I tried ZuulFilter implementation and the MyZuulFilter.run()  is call for all the localhost:1122/registrations request but not for localhost:1122/api/test </p>

<p>How can I configure the interceptor in a way that its gets executed before anything else</p>

<p>pom.xml</p>

<pre><code>&lt;parent&gt;
    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-starter-parent&lt;/artifactId&gt;
    &lt;version&gt;Angel.SR6&lt;/version&gt;
&lt;/parent&gt;
</code></pre>

<p>Thanks
Ravi</p>