resty v3.0.0-rc.1 版本更新介绍
发布日期: 2026-06-08
版本号: v3.0.0-rc.1
这是 resty v3 的第一个候选发布版本(RC1),包含了重要的错误修复和功能增强。修复涉及重试策略、多部分请求错误处理、请求头深拷贝、大小写敏感、gzip/deflate 解压器 panic 以及跨域重定向时敏感头信息的移除等。新增功能包括对 SetXXXAny 系列方法、对讲机(hedging)请求支持、基于上下文的负载均衡下一跳、重试条件接口、熔断器扩展接口、内置限速器以及 SSE 请求的设置支持等。此外,还进行了代码重构、测试改进和命名规范优化。用户可查阅升级指南和完整变更日志获取详情。
更新内容 (中文)
v3 发布候选版 1
v3 升级指南
- 升级指南:https://resty.dev/docs/upgrading-to-v3/
错误修复
- 修复:请求级别的重试延迟策略以及重试钩子和条件的执行顺序 #1033,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1096 提交
- 修复:改进多部分请求失败时的错误处理 #1030,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1101 提交
- 修复:对冲覆盖速率限制,由 @ahmet2mir 在 https://github.com/go-resty/resty/pull/1103 提交
- 修复:在 createRawRequest 中深拷贝请求头,由 @Kodecable 在 https://github.com/go-resty/resty/pull/1105 提交
- 修复:解压器、编码器和解码器中的大小写敏感问题 #1111,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1113 提交
- 修复:对冲双重包装,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1118 提交
- 修复:当响应体损坏时,gzip reader pool 使用会导致 panic,并采用类似方式处理 deflate reader,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1124 提交(链接为1124,但描述中未明确PR号,此处按原文保留链接)
- 修复:重试时 SSE 请求体的问题,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1126 提交
- 安全修复:跨域重定向时默认剥离敏感请求头,由 @Den-Sec 在 https://github.com/go-resty/resty/pull/1136 提交
- 修复:请求重试时对不可寻址的读取器返回错误,由 @mcanevet 在 https://github.com/go-resty/resty/pull/1133 提交
- 修复:新的熔断器方法返回类型,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1139 提交
- 修复:摘要认证发送无效的 userhash 字段,由 @issuj 在 https://github.com/go-resty/resty/pull/1140 提交
- 修复:将 restyError 展开为错误切片,由 @pior 在 https://github.com/go-resty/resty/pull/1155 提交
- 修复:content-disposition 值被清理,并拒绝绝对路径、父目录遍历段,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1157 提交
- 修复:在 buildCurlCmd 输出中将 URL 与 -F/-d 分离,由 @c-tonneslan 在 https://github.com/go-resty/resty/pull/1165 提交
新功能与增强
- 新功能:为请求头、查询参数和路径参数添加对
SetXXXAny方法的支持,由 @pscheid92 在 https://github.com/go-resty/resty/pull/1098 提交 - 新功能(对冲):支持对冲以减少查询端点的延迟,由 @ahmet2mir 在 https://github.com/go-resty/resty/pull/1081 提交
- 新功能(增强)!:负载均衡器的 next 方法支持使用 context,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1117 提交
- 新功能(增强):为所有对冲请求提供公平的 context deadline,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1119 提交 https://github.com/go-resty/resty/pull/1120
- 新功能(增强):添加重置器接口,适当地调用重置,改进代码和测试,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1124 提交
- 新功能(增强):优化代码流程,改进和测试用例,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1129 提交
- 新功能(增强)!:移除 HTTP 状态码检查,并为状态码添加新的可导出重试条件 #1080,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1130 提交
- 新功能(增强):为重定向头添加剥离敏感信息策略 #1128,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1134 提交
- 新功能:添加 SetLabel() 以使其对指标可见,由 @xxtanisxx 在 https://github.com/go-resty/resty/pull/1123 提交
- 新功能(增强):向熔断器实现添加接口以使其可扩展,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1138 提交
- 新功能:使用 Go 的开箱即用函数和包,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1145 提交
- 新功能(增强):使对冲实现使用接口,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1147 提交
- 新功能:添加内置的限流器实现,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1151 提交
- 新功能:支持为 SSE 设置 Transport,由 @invzhi 在 https://github.com/go-resty/resty/pull/1150 提交
- 新功能:支持为 SSE 设置 Context,由 @invzhi 在 https://github.com/go-resty/resty/pull/1154 提交
- 新功能(增强)!:重试时返回 ErrReaderNotSeekable 而不是发送空请求体,由 @pior 在 https://github.com/go-resty/resty/pull/1156 提交
- 新功能(增强)!:在重定向主机比较时不从请求 URL 的主机中剥离端口,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1159 提交
- 新功能(增强):遵循最小和最大重试等待时间中的显式零值,由 @leno23 在 https://github.com/go-resty/resty/pull/1162 提交
测试
- 测试:改进测试用例,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1099 提交
- 测试:修复不稳定的测试 TestClient_SetRootCertificateWatcher,由 @pior 在 https://github.com/go-resty/resty/pull/1158 提交
杂项
- 重构:使客户端钩子函数的参数为可变参数,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1093 提交
- 重构:优化 JSON 解码流程,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1094 提交
- 重构:将重试策略命名为重试延迟策略,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1095 提交
- 重构(增强):简化错误函数名和字段 #1062,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1097 提交
- 重构:简化命名约定以确保一致且易于发现,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1106 提交
- 重构:对冲实现,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1114 https://github.com/go-resty/resty/pull/1130 提交
- 文档:godoc 更新与改进,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1131 提交
- 杂项:版本升级至 3.0.0-rc.1,由 @jeevatkm 在 https://github.com/go-resty/resty/pull/1170 提交
新贡献者
- @pscheid92 在 https://github.com/go-resty/resty/pull/1098 进行了首次贡献
- @ahmet2mir 在 https://github.com/go-resty/resty/pull/1081 进行了首次贡献
- @Kodecable 在 https://github.com/go-resty/resty/pull/1105 进行了首次贡献
- @xxtanisxx 在 https://github.com/go-resty/resty/pull/1123 进行了首次贡献
- @Den-Sec 在 https://github.com/go-resty/resty/pull/1136 进行了首次贡献
- @mcanevet 在 https://github.com/go-resty/resty/pull/1133 进行了首次贡献
- @issuj 在 https://github.com/go-resty/resty/pull/1140 进行了首次贡献
- @c-tonneslan 在 https://github.com/go-resty/resty/pull/1165 进行了首次贡献
- @leno23 在 https://github.com/go-resty/resty/pull/1162 进行了首次贡献
完整变更日志:https://github.com/go-resty/resty/compare/v3.0.0-beta.6…v3.0.0-rc.1
更新内容 (原始)
v3 Release Candidate 1
v3 Guide
- Upgrade Guide: https://resty.dev/docs/upgrading-to-v3/
Bug Fixes
- fix: request-level retry delay strategy and execution order of retry hooks and conditions #1033 by @jeevatkm in https://github.com/go-resty/resty/pull/1096
- fix: improve error handling in the multipart request failure #1030 by @jeevatkm in https://github.com/go-resty/resty/pull/1101
- fix: hedging cover rate limit by @ahmet2mir in https://github.com/go-resty/resty/pull/1103
- fix: Deepcopy header in createRawRequest by @Kodecable in https://github.com/go-resty/resty/pull/1105
- fix: case sensitive issue in decompresser, encoder, and decoder #1111 by @jeevatkm in https://github.com/go-resty/resty/pull/1113
- fix: hedging double wrap by @jeevatkm in https://github.com/go-resty/resty/pull/1118
- fix: gzip reader pool usage panic with corrupt data response body and similar approach for deflate reader by @jeevatkm in
- fix: sse request body issue on retry by @jeevatkm in https://github.com/go-resty/resty/pull/1126
- security: strip sensitive headers on cross-domain redirects by default by @Den-Sec in https://github.com/go-resty/resty/pull/1136
- fix: return error for non-seekable readers on request retry by @mcanevet in https://github.com/go-resty/resty/pull/1133
- fix: new circuit breaker method return type by @jeevatkm in https://github.com/go-resty/resty/pull/1139
- fix: sending digest auth sending invalid userhash field by @issuj in https://github.com/go-resty/resty/pull/1140
- fix: unwrap restyError to an error slice by @pior in https://github.com/go-resty/resty/pull/1155
- fix: content-disposition values are sanitized and absolute path, parent-directory travesal segments are rejected by @jeevatkm in https://github.com/go-resty/resty/pull/1157
- fix: separate URL from -F/-d in buildCurlCmd output by @c-tonneslan in https://github.com/go-resty/resty/pull/1165
Features & Enhancements
- feat: Add support for
SetXXXAnymethods for headers, query parameters, and path parameters. by @pscheid92 in https://github.com/go-resty/resty/pull/1098 - feat(hedging): support hedging in order to reduce latency when quering endpoints by @ahmet2mir in https://github.com/go-resty/resty/pull/1081
- feat(enhancement)!: lb next method with context usage by @jeevatkm in https://github.com/go-resty/resty/pull/1117
- feat(ehancement): make fair context deadline for all hedged requests by @jeevatkm in https://github.com/go-resty/resty/pull/1119 https://github.com/go-resty/resty/pull/1120
- feat(enhancement): add resetter interface, call reset appropriately, improve code, and test by @jeevatkm in https://github.com/go-resty/resty/pull/1124
- feat(enhancement): optimize code flow, improve and test cases by @jeevatkm in https://github.com/go-resty/resty/pull/1129
- feat(enhancement)!: remove HTTP status code check and add new exported retry condition for status codes #1080 by @jeevatkm
- feat(enhancement): add redirect header strip sensitive policy #1128 by @jeevatkm in https://github.com/go-resty/resty/pull/1134
- feat: Add SetLabel() to be discoverable to metrics by @xxtanisxx in https://github.com/go-resty/resty/pull/1123
- feat(enhancement): add interface(s) into circuit breaker implementation to make it extensible by @jeevatkm in https://github.com/go-resty/resty/pull/1138
- feat: use go’s ootb function and package by @jeevatkm in https://github.com/go-resty/resty/pull/1145
- feat(enhancement): make hedging implementation to use an interface by @jeevatkm in https://github.com/go-resty/resty/pull/1147
- feat: add built-in rate limiter implementations by @jeevatkm in https://github.com/go-resty/resty/pull/1151
- feat: support SetTransport for SSE by @invzhi in https://github.com/go-resty/resty/pull/1150
- feat: support SetContext for SSE by @invzhi in https://github.com/go-resty/resty/pull/1154
- feat(enhancement)!: Return ErrReaderNotSeekable instead of sending empty bodies on retry by @pior in https://github.com/go-resty/resty/pull/1156
- feat(enhancement)!: do not strip the port from the request URL host for redirect host comparison by @jeevatkm in https://github.com/go-resty/resty/pull/1159
- feat(enhancement): honor explicit zeros in min and max retry wait time by @leno23 in https://github.com/go-resty/resty/pull/1162
Tests
- test: improve test cases by @jeevatkm in https://github.com/go-resty/resty/pull/1099
- test: fix flaky test TestClient_SetRootCertificateWatcher by @pior in https://github.com/go-resty/resty/pull/1158
Chores
- refactor: make client hook functions arg as variadic by @jeevatkm in https://github.com/go-resty/resty/pull/1093
- refactor: optimize decode json flow by @jeevatkm in https://github.com/go-resty/resty/pull/1094
- refactor: naming from retry strategy to retry delay strategy by @jeevatkm in https://github.com/go-resty/resty/pull/1095
- refactor(enhancement): streamline error function names and fields #1062 by @jeevatkm in https://github.com/go-resty/resty/pull/1097
- refactor: streamline naming conventions to enable and ensure consistent and easy discovery by @jeevatkm in https://github.com/go-resty/resty/pull/1106
- refactor: hedging implementation by @jeevatkm in https://github.com/go-resty/resty/pull/1114 in https://github.com/go-resty/resty/pull/1130
- docs: godoc update and improvements by @jeevatkm in https://github.com/go-resty/resty/pull/1131
- chore: version bump to 3.0.0-rc.1 by @jeevatkm in https://github.com/go-resty/resty/pull/1170
New Contributors
- @pscheid92 made their first contribution in https://github.com/go-resty/resty/pull/1098
- @ahmet2mir made their first contribution in https://github.com/go-resty/resty/pull/1081
- @Kodecable made their first contribution in https://github.com/go-resty/resty/pull/1105
- @xxtanisxx made their first contribution in https://github.com/go-resty/resty/pull/1123
- @Den-Sec made their first contribution in https://github.com/go-resty/resty/pull/1136
- @mcanevet made their first contribution in https://github.com/go-resty/resty/pull/1133
- @issuj made their first contribution in https://github.com/go-resty/resty/pull/1140
- @c-tonneslan made their first contribution in https://github.com/go-resty/resty/pull/1165
- @leno23 made their first contribution in https://github.com/go-resty/resty/pull/1162
Full Changelog: https://github.com/go-resty/resty/compare/v3.0.0-beta.6...v3.0.0-rc.1