Skip to content

Ability to set custom interceptor on client via additionalSettings (HttpClientFactoryAdditionalSettings) or another clean way. #241

@wizpar

Description

@wizpar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions