Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#241 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
java
领域
api

调研方向

首先阅读 ApiClient 和 HttpClientFactoryAdditionalSettings,重点关注每次调用的客户端是如何构建的,以及 logger 和 retry 拦截器是如何提供的。当调用方拥有一种受支持的方式,可以在不使用 reflection 的情况下添加可复用的自定义拦截器,并包括所请求的访问或注入路径时,这项工作就完成了。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Java
星标
29
派生
50
平均合并
1 小时 30 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

CyberSource/cybersource-rest-client-java 的其他 Issue

查看 CyberSource/cybersource-rest-client-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。