映射查询字符串或表单参数

  1. POST /post?ids[a]=1234&ids[b]=hello HTTP/1.1
  2. Content-Type: application/x-www-form-urlencoded
  3. names[first]=thinkerou&names[second]=tianou
  1. func main() {
  2. router := gin.Default()
  3. router.POST("/post", func(c *gin.Context) {
  4. ids := c.QueryMap("ids")
  5. names := c.PostFormMap("names")
  6. fmt.Printf("ids: %v; names: %v", ids, names)
  7. })
  8. router.Run(":8080")
  9. }
  1. ids: map[b:hello a:1234], names: map[second:tianou first:thinkerou]