gin Bind 参数绑定

February 25, 2023

gin Bind 参数绑定。

type params struct {
	Total int `form:"total" json:"total" binding:"omitempty,numeric"`
}

Bind和ShouldBind 区别

区别就是Bindxxx会的返回400http状态码错误,而Shouldxxx不会用户可以自定义错误码。

ShouldBind

绑定不是GET请求的 json 参数,但可以绑定成功POST请求的 json 参数。

ShouldBindJSON

绑定 json 参数。

Go

IARNO

服务端开发

gin binding tag