mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 18:22:23 +08:00
add readme for query map
This commit is contained in:
parent
3b4c0f1325
commit
9e1cbfca1b
29
README.md
29
README.md
@ -26,6 +26,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi
|
|||||||
- [Querystring parameters](#querystring-parameters)
|
- [Querystring parameters](#querystring-parameters)
|
||||||
- [Multipart/Urlencoded Form](#multiparturlencoded-form)
|
- [Multipart/Urlencoded Form](#multiparturlencoded-form)
|
||||||
- [Another example: query + post form](#another-example-query--post-form)
|
- [Another example: query + post form](#another-example-query--post-form)
|
||||||
|
- [Map as querystring or postform parameters](#map-as-querystring-or-postform-parameters)
|
||||||
- [Upload files](#upload-files)
|
- [Upload files](#upload-files)
|
||||||
- [Grouping routes](#grouping-routes)
|
- [Grouping routes](#grouping-routes)
|
||||||
- [Blank Gin without middleware by default](#blank-gin-without-middleware-by-default)
|
- [Blank Gin without middleware by default](#blank-gin-without-middleware-by-default)
|
||||||
@ -315,6 +316,34 @@ func main() {
|
|||||||
id: 1234; page: 1; name: manu; message: this_is_great
|
id: 1234; page: 1; name: manu; message: this_is_great
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Map as querystring or postform parameters
|
||||||
|
|
||||||
|
```
|
||||||
|
POST /post?ids[a]=1234&ids[b]=hello HTTP/1.1
|
||||||
|
Content-Type: application/x-www-form-urlencoded
|
||||||
|
|
||||||
|
names[first]=thinkerou&names[second]=tianou
|
||||||
|
```
|
||||||
|
|
||||||
|
```go
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
ids: map[b:hello a:1234], names: map[second:tianou first:thinkerou]
|
||||||
|
```
|
||||||
|
|
||||||
### Upload files
|
### Upload files
|
||||||
|
|
||||||
#### Single file
|
#### Single file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user