رفتن به محتوا

Map as querystring or postform parameters

Terminal window
POST /post?ids[a]=1234&ids[b]=hello HTTP/1.1
Content-Type: application/x-www-form-urlencoded
names[first]=thinkerou&names[second]=tianou
Terminal window
curl 'http://localhost:8080/post?ids\[a\]=1234&ids\[b\]=hello' \
--data-raw 'names[first]=pure&names[seconds]=maslak' \
--compressed
func main() {
router := gin.Default()
router.POST("/post", func(c *gin.Context) {
ids := c.QueryMap("ids")
names := c.PostFormMap("names")
fmt.Printf("ids: %v; names: %v", ids, names)
})
router.Run(":8080")
}
Terminal window
ids: map[b:hello a:1234], names: map[second:tianou first:thinkerou]