gin v1.7.0 版本更新介绍
发布日期: 2021-04-08
版本号: v1.7.0
本次更新修复了若干问题,包括解决#2572引入的编译错误、修复连接中断时请求头打印异常问题以及修复路由树节点路径未更新的问题。功能改进方面新增了参数路由支持并避免路由冲突,优化了字符串渲染性能与参数计数效率,同步最新路由树代码,新增自定义恢复中间件及GetUint/Uint64方法,修复32位系统时间戳溢出问题,增强基础认证安全性,改进内容描述头的MIME格式兼容性。同时包含多项代码优化:重命名初始化函数、移除冗余代码、添加POST重定向示例、支持map绑定、修复切片绑定问题,并改进代理信任配置和远程IP获取机制。
更新内容 (中文)
BUG修复
- 修复由 #2572 引起的编译错误 (#2600)
- 修复管道破裂时未携带
Authorization
头部的请求头打印问题 (#2528) - 修复路由树注册新节点时未重新分配完整路径的问题 (#2366)
功能增强
- 支持参数和精确路由定义且避免冲突 (#2663)
- 优化渲染字符串性能 (#2365)
- 同步路由树至 httprouter 最新代码 (#2368)
- 重命名
getQueryCache
/getFormCache
为initQueryCache
/initFormCache
(#2375) - 性能优化:改进
countParams
函数 (#2378) - 移除与标准库
bytes
包功能重复的代码 (#2387) - 更新
SetMode
函数逻辑 (#2321) - 移除未使用的类型
SecureJSONPrefix
(#2391) - 新增 POST 方法重定向示例 (#2389)
- 添加内置中间件
CustomRecovery
(#2322) - 绑定模块:避免 32 位架构的 2038 年问题 (#2450)
- 防止
Context.GetQuery()
在无请求时触发 panic (#2412) - 为
gin.Context
添加GetUint
和GetUint64
方法 (#2487) - 将
content-disposition
头部更新为 MIME 风格 (#2512) - 减少内存分配并优化渲染模块的
WriteString
性能 (#2508) - 为
Error
类型实现.Unwrap() error
方法 (#2525) (#2526) - 允许通过
map[string]string
进行数据绑定 (#2484) - 维护:更新路由树逻辑 (#2371)
- 支持切片/数组对象绑定 [重构实现] (#2302)
- 基础认证:修复时序攻击漏洞 (#2609)
- 支持混合参数路径与非参数路径 (移植自 httprouter #329) (#2663)
- 新增引擎配置项
TrustedProxies
与RemoteIP
(#2632)
更新内容 (原始)
BUGFIXES
- fix compile error from #2572 (#2600)
- fix: print headers without Authorization header on broken pipe (#2528)
- fix(tree): reassign fullpath when register new node (#2366)
ENHANCEMENTS
- Support params and exact routes without creating conflicts (#2663)
- chore: improve render string performance (#2365)
- Sync route tree to httprouter latest code (#2368)
- chore: rename getQueryCache/getFormCache to initQueryCache/initFormCa (#2375)
- chore(performance): improve countParams (#2378)
- Remove some functions that have the same effect as the bytes package (#2387)
- update:SetMode function (#2321)
- remove a unused type SecureJSONPrefix (#2391)
- Add a redirect sample for POST method (#2389)
- Add CustomRecovery builtin middleware (#2322)
- binding: avoid 2038 problem on 32-bit architectures (#2450)
- Prevent panic in Context.GetQuery() when there is no Request (#2412)
- Add GetUint and GetUint64 method on gin.context (#2487)
- update content-disposition header to MIME-style (#2512)
- reduce allocs and improve the render
WriteString
(#2508) - implement “.Unwrap() error” on Error type (#2525) (#2526)
- Allow bind with a map[string]string (#2484)
- chore: update tree (#2371)
- Support binding for slice/array obj [Rewrite] (#2302)
- basic auth: fix timing oracle (#2609)
- Add mixed param and non-param paths (port of httprouter#329) (#2663)
- feat(engine): add trustedproxies and remoteIP (#2632)