Я пытался добавить http-перехватчик в мой вызов RepositoryRestResource с помощью WebMvcConfigurer, но мой перехватчик вызывается для всех полученных запросов, кроме запроса для моего репозитория
// CLASS: SPRING BOOT APPLICATION
@SpringBootApplication
@EnableWebMvc
public class myApplication {
public static void main(String[] args) {
SpringApplication.run(myApplication .class, args);
}
}
// CLASS: GCP DATA STORE REPOSITORY
@RepositoryRestResource
public interface PassportRepository extends DatastoreRepository<Passport, String> {
}
// CLASS: MVC CONFIG
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Autowired
MyInterceptor myInterceptor ;
@Override
public void addInterceptors(InterceptorRegistry registry){
registry.addInterceptor(myInterceptor).addPathPatterns("/**");
}
}
// CLASS: INTERCEPTOR
@Component
public class MyInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) {
System.out.println("TEST!");
return true;
}
}
Когда я позвонил: http://localhost:8080/passports/1234 Я ожидал, что мой перехватчик запишет "ТЕСТ", но это не так.
Когда я позвонил http://localhost:8080/anythingelse. Мой перехватчик вошел в ТЕСТ
Что я сделал не так?