Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增 apache http builder,支持 apache http client #315

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Masutangu
Copy link
Contributor

@Masutangu Masutangu commented Nov 25, 2024

新增 apache http builder,支持 apache client

使用示例:
// 初始化商户配置
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(merchantId)
.privateKeyFromPath(privateKeyPath)
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(apiV3Key)
.build();

// 创建 HttpClient
HttpClient httpClient = new ApacheHttpClientBuilder().config(config).build();

// 构造 HttpRequest,以 GET 为例
HttpRequest httpRequest =
new HttpRequest.Builder()
.httpMethod(HttpMethod.GET)
.url(requestPath)
.headers(headers)
.build();

// 发送请求 Response 为自定义的回包的类型
HttpResponse httpResponse =
httpClient.execute(httpRequest, Response.class);

@xy-peng
Copy link
Contributor

xy-peng commented Nov 29, 2024

如何使用,能否补充个文档,或者在 pr 中说明

@xy-peng
Copy link
Contributor

xy-peng commented Dec 4, 2024

建议再增加一个实现CloseableHttpClient 的类,内部组合一个 ApacheHttpClientAdapter,实现发包的功能。这样从 wechatpay-apache-httpclient 迁移的开发者,只需要切换配置部分,而不用改动具体的业务代码。

@EmmetZC
Copy link
Contributor

EmmetZC commented Dec 13, 2024

建议再增加一个实现CloseableHttpClient 的类,内部组合一个 ApacheHttpClientAdapter,实现发包的功能。这样从 wechatpay-apache-httpclient 迁移的开发者,只需要切换配置部分,而不用改动具体的业务代码。

CloseableHttpClient 的实现不是很好弄,先把这个合进去让提供 ApacheHttpClient 的兼容支持。

怎么提供更高效的迁移支持我们下周再想办法。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants