Hi everyone.
In my application, I use configurations of rest clients like this
@FeignClient(value = "TestClient", url = "${test.url:#{null}}", configuration = ApplicationAuthenticationConfig.class)
in ApplicationAuthenticationConfig I do:
`public class ApplicationAuthenticationConfig{
@Bean
public RequestInterceptor jwtInterceptor() {
return new FeignConfig.JwtInterceptor();
}
}`
As I have multiple feign clients with ApplicationAuthenticationConfig, there occurs multiple JwtInterceptors created. they all follow same functionality and I would like to create only one JwtInterceptor.
If I make ApplicationAuthenticationConfig a @Configuration, JwtInterceptor will be applied to the clients they are not needed.
What I would like to see is when I specify the configuration, only request interceptors from this configuration are applied
Comment From: OlgaMaciaszek
Hello, @kampaii53, thanks for opening the issue. There are separate contexts created for each OF client, so there has to be a separate interceptor per client.
Comment From: kampaii53
Hi, @OlgaMaciaszek ! the issue is - when we introduce some global interceptors(as components of global context for example), they are applied in addition to separate context of a client. So a possibility to fetch only interceptors of the configuration should be great.
Reason: Interceptor can be a heavy-weight component so we don't want more than one instance of that. We can use interceptor as a lightweight wrapper, but I think it is better to give an option to select/exclude interceptors in configuration
Comment From: OlgaMaciaszek
I'm afraid that's how the Boot context config works - you can either have one in the parent application context (applied everywhere) or ones in the child contexts (OF client contexts) only visible for that particular client. Maybe you could try working with conditions within the interceptor - have one in the main contexts but filter the requests to apply the logic to within it?
Comment From: kampaii53
That's almost the approach im using right now. The thing I want to propose here is to create a mod to feign client builder. Once enabled, it would make builder autowire only beans registered in configuration = ApplicationAuthenticationConfig.class.
Comment From: kampaii53
Also wanted to mention that feign automatically adding all feign beans from context is not intuitive. I have surprized my colleagues when discovered this
Comment From: OlgaMaciaszek
Ok, I don't think we will work on anything similar at this point. If you figure out an improved way, feel free to create a PR - will review.