package
Version:
v0.0.0-...-a23e254
Opens a new window with list of versions in this module.
Published: Aug 13, 2020
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
HelloForm 将�form表单提绑定到 struct 上,form-data
这里有 Bind, BindJSON, BindQuery 和 ShouldBind, ShouldBindJSON, ShouldBindQuery 这6中绑定方法
加上 should 就是根据 content-type 一定的自我判定能力,代价就是损耗一些性能
HelloPage 基本示例,返回 json 格式内容
type HelloValForm struct {
User string `form:"user" json:"user" binding:"required"`
Password string `form:"password" json:"password" binding:"required"`
Time time.Time `form:"time" json:"time" binding:"required,bookabledate" time_format:"2006-01-02"`
}
type LoginForm struct {
User string `form:"user" json:"user" binding:"required"`
Password string `form:"password" json:"password" binding:"required"`
}
LoginForm 在标签中就是映射要读取的字段,同时可以进行字段验证
Source Files
¶
Click to show internal directories.
Click to hide internal directories.