gin v1.3.0 版本更新介绍
发布日期: 2018-08-14
版本号: v1.3.0
Gin 1.3.0版本主要新增了多个功能:添加了QueryMap、GetQueryMap、PostFormMap和GetPostFormMap方法以支持map类型参数处理;新增AsciiJSON方法生成ASCII字符的JSON响应;在ResponseWriter中增加Pusher()支持HTTP/2推送;引入DataFromReader方法处理动态数据;添加ShouldBindBodyWith支持多次绑定请求体;增强表单绑定功能,支持指针类型、默认值和时区设置。其他更新包括JSONP方法、日志显示查询字符串、SecureJSON防劫持前缀,以及暴露验证器引擎。弃用了GetCookie方法,改用Cookie方法。修复了控制台颜色禁用失效、Gin空模式返回Debug模式问题,以及Flush()方法覆盖状态码的问题。
更新内容 (中文)
更新日志
Gin 1.3.0
- [新增] 添加
func (*Context) QueryMap
、func (*Context) GetQueryMap
、func (*Context) PostFormMap
和func (*Context) GetPostFormMap
,支持type map[string]string
作为查询字符串或表单参数,详见 #1383 - [新增] 添加
func (*Context) AsciiJSON
,详见 #1358 - [新增] 在
type ResponseWriter
中添加Pusher()
以支持 HTTP/2 服务器推送,详见 #1273 - [新增] 添加
func (*Context) DataFromReader
用于动态数据服务,详见 #1304 - [新增] 添加
func (*Context) ShouldBindBodyWith
支持多次调用绑定方法,详见 #1341 - [新增] 支持表单绑定中的指针类型,详见 #1336
- [新增] 添加
func (*Context) JSONP
,详见 #1333 - [新增] 支持表单绑定的默认值,详见 #1138
- [新增] 在
type StructValidator
中公开验证器引擎,详见 #1277 - [新增] 添加
func (*Context) ShouldBind
、func (*Context) ShouldBindQuery
和func (*Context) ShouldBindJSON
,详见 #1047 - [新增] 支持表单绑定中的
time.Time
时区设置,详见 #1117 - [新增] 添加
func (*Context) BindQuery
,详见 #1029 - [新增] 通过构建标签使 jsonite 成为可选依赖,详见 #1026
- [新增] 在日志中显示查询字符串,详见 #999
- [新增] 添加
func (*Context) SecureJSON
,详见 #987 和 #993 - [弃用] 弃用
func (*Context) GetCookie
,改用func (*Context) Cookie
- [修复] 调用
func DisableConsoleColor
后不再显示颜色标签,详见 #1072 - [修复] 调用
func Mode
时空模式返回const DebugMode
,详见 #1250 - [修复]
Flush()
现在不会覆盖responseWriter
的状态码,详见 #1460
更新内容 (原始)
CHANGELOG
Gin 1.3.0
- [NEW] Add
func (*Context) QueryMap
,func (*Context) GetQueryMap
,func (*Context) PostFormMap
andfunc (*Context) GetPostFormMap
to supporttype map[string]string
as query string or form parameters, see #1383 - [NEW] Add
func (*Context) AsciiJSON
, see #1358 - [NEW] Add
Pusher()
intype ResponseWriter
for supporting http2 push, see #1273 - [NEW] Add
func (*Context) DataFromReader
for serving dynamic data, see #1304 - [NEW] Add
func (*Context) ShouldBindBodyWith
allowing to call binding multiple times, see #1341 - [NEW] Support pointers in form binding, see #1336
- [NEW] Add
func (*Context) JSONP
, see #1333 - [NEW] Support default value in form binding, see #1138
- [NEW] Expose validator engine in
type StructValidator
, see #1277 - [NEW] Add
func (*Context) ShouldBind
,func (*Context) ShouldBindQuery
andfunc (*Context) ShouldBindJSON
, see #1047 - [NEW] Add support for
time.Time
location in form binding, see #1117 - [NEW] Add
func (*Context) BindQuery
, see #1029 - [NEW] Make jsonite optional with build tags, see #1026
- [NEW] Show query string in logger, see #999
- [NEW] Add
func (*Context) SecureJSON
, see #987 and #993 - [DEPRECATE]
func (*Context) GetCookie
forfunc (*Context) Cookie
- [FIX] Don’t display color tags if
func DisableConsoleColor
called, see #1072 - [FIX] Gin Mode
""
when callingfunc Mode
now returnsconst DebugMode
, see #1250 - [FIX]
Flush()
now doesn’t overwriteresponseWriter
status code, see #1460