Gin 使用示例(四):绑定查询字符串或 POST 数据
由 学院君 创建于5个月前, 最后更新于 5个月前
版本号 #3
780 views
0 likes
0 collects
示例代码(src/gin-demo/examples/request_data.go):
package main
import (
"github.com/gin-gonic/gin"
"log"
"time"
)
type Person struct {
Name string `form:"name"`
Address string `form:"address"`
Birthday time.Time `form:"birthday" time_format:"2006-01-02" time_utc:"1"`
}
func startPage(c *gin.Context) {
var person Person
// If `GET`, only `Form` binding engine (`query`) used.
// If `POST`, first checks the `content-type` for `JSON` or `XML`, then uses `Form` (`form-data`).
// See more at