CyberSource / CyberSource/cybersource-rest-client-java
Ability to set custom interceptor on client via additionalSettings (HttpClientFactoryAdditionalSettings) or another clean way.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 29
- Forks
- 50
- Avg merge
- 28m
- Merged PRs (30d)
- 1
Description
Hi,
previously in 0.81 and lower versions it was possible to do something like so
apiClient.setHttpClient(
apiClient
.getHttpClient()
.newBuilder()
.addInterceptor(new ApiClientDebugModeInterceptor())
.build());
add a custom interceptor and use that to gather debug info etc (not just logging to logger/or retry metrics etc)..
since 0.82 client creation is per call level and it has change to only allow
HttpClientFactoryAdditionalSettings to set a http logger and one for retry interceptor
and also this additionalSettings is a private field in ApiClient
so there is no way to pass in a custom interceptor to be added to the client builder phase (per request or as a class field to be re used).
I would like to request support to allow ApiClient users to
have access to this additionalSettings via a getter or have a way to pass in a vanilla Interceptor to be added to the call chain to do other custom work outside of logging/retry (in our case for example we have a debug mode where we gather headers/request body/response body and store it in some fields and do some debug logic from said object).
I can technically use reflections and access this additionalSettings and then instead of the custom retry interceptor use my own interceptor but that is not clean.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ApiClient and HttpClientFactoryAdditionalSettings, focusing on how the per-call client is built and how logger and retry interceptors are supplied. The work is done when callers have a supported way to add a reusable custom interceptor without reflection, including the requested access or injection path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100