1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 21:02:25 +08:00
Commit Graph

50 Commits

Author SHA1 Message Date
is-Xiaoen
30c8e77246 fix: improve type safety in httpWithTLS for custom RoundTripper (#861)
* fix: improve type safety in httpWithTLS for custom RoundTripper

Add type assertion check to handle cases where DefaultHTTPClient.Transport
is a custom http.RoundTripper implementation (not *http.Transport).

This improves upon the fix in PR #844 which only handled nil Transport.
The previous code would still panic if users set a custom RoundTripper:

  trans := baseTransport.(*http.Transport).Clone()  // panic if not *http.Transport

Now safely handles three scenarios:
1. Transport is nil -> use http.DefaultTransport
2. Transport is *http.Transport -> clone it
3. Transport is custom RoundTripper -> use http.DefaultTransport

Added comprehensive test cases:
- TestHttpWithTLS_NilTransport
- TestHttpWithTLS_CustomTransport
- TestHttpWithTLS_CustomRoundTripper

Related to #803

* refactor: reduce code duplication and complexity in httpWithTLS

- Eliminate duplicate http.DefaultTransport.Clone() calls
- Reduce cyclomatic complexity by simplifying conditional logic
- Use nil check pattern instead of nested else branches
- Maintain same functionality with cleaner code structure

This addresses golangci-lint warnings for dupl and gocyclo.

* fix: add newline at end of http_test.go

Fix gofmt -s compliance issue:
- File must end with newline character
- Addresses golangci-lint gofmt error on line 81

This fixes CI check failure.
2025-10-27 14:24:24 +08:00
zhangjiani
d4a81916d5 fix: handle JSON parse error when API returns binary file instead of error JSON (#852)
Co-authored-by: tax <jia_deng@intsig.net>
2025-09-14 19:47:00 +08:00
silenceper
ee5f045b89 fix panic (#844) 2025-07-24 09:59:13 +08:00
litterGuy
23bb10b0c9 fix: ImageUpload 接口报错 'media data missing hint:' (#832) 2025-04-27 10:08:51 +08:00
oah8
c1770130a0 add stream_upload_source (#786)
Co-authored-by: _oah <57302072@qq.com>
2024-08-22 14:21:58 +08:00
sam
6b3532cc2d feat: Material 增加 AddMaterialFromReader 与 AddVideoFromReader 方法 (#780)
* feat: Material 增加 AddMaterialFromReader 与 AddVideoFromReader 方法

* update: 调整 PostFileFromReader 参数。
2024-07-16 15:43:18 +08:00
oscar
97e1af5904 支持设置全局HTTPClient (#761)
* [新增]支持设置httpClient

* 增加说明

* 增加说明

* 格式化imports

* [fix]1.21.5 和golangci 有兼容性问题

* [fix]优化imports
2024-01-02 17:19:59 +08:00
zxfishhack
a5e674bf10 支持在请求前修改各api的地址 (#736)
* 增加URI修改接口,以支持正向代理

* Update http.go

* Update http.go
2023-11-02 09:44:08 +08:00
houseme
26b0aacb4c feat: create mini program virtual payment (#709) 2023-08-21 22:09:30 +08:00
jingyuexing
8bae546b77 Improve developer experience (#681)
* feat: 添加query 以及query单元测试
feat: 添加模板字符串解析以及模板字符串单元测试

* improve: 序列化请求参数,使得参数更易读

* delete: delete useless module

* format: format code

* docs: add function comment

* docs: comment method

* fix: fixed type convert error

* feat: support any type

* feat: support other type

* format: format code

* test: check logger

* format: format code

* test: udpate testing case

* del: remove useless code

* del: remove useless module

* test: update testing case

*  feat: support for unsigned integers

*  feat: template string support any type
2023-05-31 17:26:43 +08:00
okhowang
07b7dc40fc cache增加带Context版本,开放平台相关接口支持Context版本 (#653) 2023-04-03 20:32:44 +08:00
houseme
a8f7a24ff6 feat: improve comment and upgrade golang version 1.16 (#604)
* feat: improve action config and code comment

* feat: improve comment and upgrade golang version 1.16

* feat: improve import
2022-08-23 10:13:24 +08:00
Wangrong
37f9e981d6 客服管理功能添加 (#600) 2022-08-13 12:24:12 +08:00
stepbystep2
fdaffb6aa2 fix: typo (#595) 2022-08-02 20:16:38 +08:00
stepbystep2
108a65ecf3 添加GetPhoneNumberContext方法 (#587) 2022-07-28 00:08:08 +08:00
houseme
adf142dac2 feat: modify redis version to v8.11.5 (#582)
* [feature] Format the code and improve Mini Program authorization to obtain openid(miniprogram/auth/auth.go Code2Session)

* [feature] CheckEncryptedData (https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.checkEncryptedData.html)

* upgrade json error

* upgrade json error

* [feature] Wallet Transfer returns the pointer object

* feat:Adaptation of new go-redis components

* improve code

* feat:upgrade golangci-lint-action version

* fix

* test ci

* fix

* test ci

* fix

* test

* improve code

* feat:GetPhoneNumber return ptr

* fix: ptr Elem() error

* improve code

* improve code

* improve code

* improve code

* upgrade go version v1.15

* improve .golangci.yml

* feat:modify redis version v8.11.5

Co-authored-by: houseme <houseme@outlook.com>
2022-07-20 11:25:15 +08:00
sū hǎi
f2e7979a9f return *CommonError instead of errorString (#568) 2022-05-17 10:33:53 +08:00
okhowang
1e2f909f34 小程序auth增加Context接口 (#483) 2021-09-17 10:11:22 +08:00
houseme
96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473)
* [feature] Format the code and improve Mini Program authorization to obtain openid(miniprogram/auth/auth.go Code2Session)

* [feature] CheckEncryptedData (https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.checkEncryptedData.html)

* upgrade json error

* upgrade json error

Co-authored-by: houseme <houseme@outlook.com>
2021-09-08 11:03:23 +08:00
Afeyer
1005807328 添加企业微信会话存档SDK (#419)
* 添加企业微信会话存档SDK

* 更新说明文档

* 更新包名为msgaudit并更新说明文档

* 迁移会话存档SDK到work目录下

* 移动RSA文件到util并添加动态库文件

* 整合企业微信和会话存档配置文件

* 修复golangcli-lint提示中的错误

* 对整个项目进行gofmt

* 更新会话存档说明文档

* 会话存档消息获取是抛出error

* 更新会话存档说明文档

Co-authored-by: Afeyer <afeyer@h5base.cn>
2021-07-22 17:45:14 +08:00
silenceper
5d8fd1f5bd fix 恢复直接使用enc.SetEscapeHTML参数 (#412)
Co-authored-by: zhenlinwen <zhenlinwen@tencent.com>
2021-06-23 09:49:41 +08:00
GargantuaX
e7fdcf9534 支持公众号账号迁移,获取openID变化接口 (#370)
* * 公众号菜单管理,set相关函数,返回btn本身,方便以字面量的方式创建多个菜单,更直观,方便管理

* * golangci-lint fix

* * 获取二维码ticket接口没有往上抛接口错误

* * 增加GetOpenID方法,以获取消息的生产用户openID

* * 支持公众号账号迁移,获取openID变化接口

* * bugfix

* * golint fix

* * golint fix
2021-03-01 15:38:54 +08:00
LouGaZen
d5a67eaf29 微信支付 - 退款通知 (#359)
* 🆕 发起退款 - 添加notify_url参数

* 🆕 退款通知
2021-02-07 09:49:43 +08:00
silenceper
c0da806e03 update golangci (#349)
* update golangci
2020-11-26 12:25:57 +08:00
silenceper
3014901b48 补全 golint (#322) 2020-08-27 16:33:42 +08:00
silenceper
868b31cb3d fix golangci-lint failed (#284)
* fix golangci-lint error
2020-06-24 14:36:33 +08:00
EvaCcino
69d0b94fdf fix:修复微信回调signType为空的问题 #282 (#283)
Co-authored-by: Avtion <manaitao@heywoods.cn>
2020-06-23 13:26:15 +08:00
huang wei
c14c020a3c fix some bugs (#277)
* fix payRequset xml marshal: root element should be xml

* support HMAC-SHA256 for unifiedorder api

* support HMAC-SHA256 for PaidVerifySign

* fix SignType is nil

* fix code style

* constantize SignType

* add comments

* fix code style
2020-06-14 23:23:58 +08:00
silenceper
15ebd71a04 规范目录 2020-01-20 13:54:04 +08:00
silenceper
96678d2279 增加小程序-云开发http api 2019-11-26 13:09:36 +08:00
silenceper
3be94cd80d Merge pull request #118 from akikistyle/add-refund
添加退款接口,util http增加CA证书
2019-04-23 21:12:06 +08:00
sunyaqiu
e66652f4b5 fix comment 2019-04-06 15:28:31 +08:00
sunyaqiu
f4f1860e67 fix some comment and struct field 2019-04-06 15:24:40 +08:00
sunyaqiu
02b3fcc648 add refund 2019-04-06 14:59:38 +08:00
jefferwang(王俊锋)
61476d351d add PostJSONWithRespContentType 2019-02-19 15:11:45 +08:00
Chyroc
188703be23 add: user update-remark api
* add DecodeWithCommonError function
* add UpdateRemark method
2018-09-14 09:25:50 +08:00
wenzl
ae0594cfeb fix golint 2018-02-23 16:28:56 +08:00
Mongo
f7b6cff271 change crypt method to MD5 2017-11-01 21:46:26 +08:00
Mongo
a9bfce3fbe fix signature calculate 2017-10-31 19:22:43 +08:00
Mongo
a4a567e1d4 add H5 payment support 2017-10-29 21:01:27 +08:00
Mongo
97752d09a6 add jsapi payment demo version 2017-10-28 00:32:08 +08:00
silenceper
f37e318f05 enc.SetEscapeHTML 支持版本>=1.7,使用简单替换 #15 2017-02-13 00:38:02 +08:00
silenceper
7c4b8fe172 json marshal改为encode ,不转义html字符(例如:&) #15 2017-02-13 00:25:14 +08:00
wenzl
6727746f71 remove unused code 2016-09-19 23:32:47 +08:00
wenzl
11cca83c5e format 2016-09-19 20:10:48 +08:00
wenzl
85fa02b00d 符合gilint规范 2016-09-19 20:00:01 +08:00
wenzl
4333691b37 oauth2,jssdk 2016-09-15 01:39:15 +08:00
wenzl
d9075933c1 实现access_token获取 2016-09-11 13:16:15 +08:00
wenzl
33f2b2ef60 支持文本消息的回复 2016-09-11 00:27:37 +08:00
wenzl
e713b4ffb2 实现消息解密 2016-09-10 11:53:06 +08:00