-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Add @Interceptor annotation to make HandlerInterceptors easier to register #40360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure exactly what you're trying to do, but perhaps |
The idea is that in spring boot spirit, i.e minimal manual configuration, it would be nice to have an |
Given that the I guess you're looking for something like this: @Interceptor(pathPatterns="/foo/*")
class MyInterceptor implements HandlerInterceptor {
...
} Which is a little more concise than: @Bean
public WebMvcConfigurer myConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addWebRequestInterceptor(new MyInterceptor()).addPathPatterns("/foo/*");
}
};
} This still feels like a Spring Framework feature to me, especially as the I'll flag this one for team-attention to see what other folks in the team think. |
This feels like a Spring Framework issue to me too. I don't think we should have a Boot-specific annotation for automatic registration of Framework's |
Thanks for the proposal, but this is indeed a Spring Framework enhancement request. This was already requested and declined in the past. In the meantime, there is less focus on the Closing as a duplicate of spring-projects/spring-framework#9447 |
It feels like there should be an
@Interceptor
annotation the way that spring has@Service
,@Repository
, etc. I think it would be a good idea to include such an annotation with values equivalent to.addPathPatterns
,.excludePathPatterns
, maybe something likeorder
to facilitate chaining and so on and have spring boot auto config take care of registering it instead of having to create aWebMvcConfigurer
The text was updated successfully, but these errors were encountered: