Skip to content

Commit

Permalink
feat(web): add method to get OkHttpClient with given list of intercep…
Browse files Browse the repository at this point in the history
…tors added
  • Loading branch information
kirangodishala committed Dec 26, 2024
1 parent 2fef420 commit cd84e46
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.netflix.spinnaker.config.ServiceEndpoint;
import com.netflix.spinnaker.kork.exceptions.SystemException;
import java.util.List;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import org.springframework.stereotype.Component;

Expand All @@ -41,8 +42,13 @@ public OkHttpClientProvider(List<OkHttpClientBuilderProvider> providers) {
* @return okHttpClient
*/
public OkHttpClient getClient(ServiceEndpoint service) {
OkHttpClientBuilderProvider provider = findProvider(service);
return provider.get(service).build();
return getClient(service, List.of());
}

public OkHttpClient getClient(ServiceEndpoint service, List<Interceptor> interceptors) {
OkHttpClient.Builder builder = findProvider(service).get(service);
interceptors.forEach(builder::addInterceptor);
return builder.build();
}

private OkHttpClientBuilderProvider findProvider(ServiceEndpoint service) {
Expand Down

0 comments on commit cd84e46

Please sign in to comment.