标签:nil start log efault art rtp get pre person
ShouldBindQuery
函数只绑定Get参数,不绑定post数据
package main import ( "log" "github.com/gin-gonic/gin" ) type Person struct { Name string `form:"name"` Address string `form:"address"` } func main() { route := gin.Default() route.Any("/testing", startPage) route.Run(":8085") } func startPage(c *gin.Context) { var person Person if c.ShouldBindQuery(&person) == nil { log.Println("====== Only Bind By Query String ======") log.Println(person.Name) log.Println(person.Address) } c.String(200, "Success") }
标签:nil start log efault art rtp get pre person
原文地址:https://www.cnblogs.com/yzg-14/p/13143596.html