0

I'd like to exclude this endpoint URL from my global interceptor (the whole Controller):

@RequestMapping(value = "/api/rest/v1/company/{companyId}/store")
@RestController()
@RequiredArgsConstructor
@Slf4j
public class StoreController {


@GetMapping(with request params)

@PostMapping()

I tried many options like:

 @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(new GlobalInterceptor(taService, authService))
                .excludePathPatterns("**/store")
                .pathMatcher(new AntPathMatcher());
    }

but without success.

Additionally I want to exclude patterns with query parameters like:

/api/rest/v1/company/{companyId}/store?param1=abc&param2=def

And probably I should exclude all Swagger urls

Matley
  • 1,953
  • 4
  • 35
  • 73
  • This post may helps you : https://stackoverflow.com/questions/34970179/exclude-spring-request-handlerinterceptor-by-path-pattern ? – JHDev Mar 23 '21 at 12:06
  • Does this answer your question? [Exclude Spring Request HandlerInterceptor by Path-Pattern](https://stackoverflow.com/questions/34970179/exclude-spring-request-handlerinterceptor-by-path-pattern) – Sachin Gorade Mar 23 '21 at 12:45

1 Answers1

0

I found a solution (there was missing slash "/"):

 @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(new GlobalInterceptor(taService, authService))
                .excludePathPatterns("/**/store")
                .pathMatcher(new AntPathMatcher());
    }
Matley
  • 1,953
  • 4
  • 35
  • 73