I would like my HandlerInterceptor, in my spring boot application, not to run on requests coming in on the management port.
management.port = 9091
I can think of 2 ways to do it, but i'm looking for a more standard way.
One will be to check the port from within the HandlerInterceptor:
@Override
public boolean preHandle(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) {
if(request.getLocalPort() == managementPort){
return true;
}
else{
....
}
}
The second will be to exclude all paths, related to the managementPort when registering the interceptor:
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(myInterceptor).excludePathPatterns(managementPortEndpoints);
}
This can easily get out of sync.
Is there a more native way to achieve it? (spring configuration of some sort)
question from:
https://stackoverflow.com/questions/66053501/handlerinterceptor-spring-exclude-requests-on-management-port 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…