-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map as query parameter suuport Bind #2606
Comments
It seems that it will be supported in v1.7 |
@Doarakko Thank you for pointing that out. I update my gin dependency to the latest, but it still doesn't work. I think what that MR solves is to bind a map, as I need to bind a struct with a map embedded. It's different. |
@hyzgh |
mark: this feature is still not suppoted by gin. |
Somehow, the *gin.Context provides a method called package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
type Req struct {
Ext map[string]string `form:"ext"`
}
func main() {
r := gin.Default()
r.GET("/map", func(c *gin.Context) {
ext := c.QueryMap("ext")
fmt.Println(ext)
// output: map[foo:bar]
f := Req{}
// Take notice of this sentence
f.Ext = c.QueryMap("Ext")
fmt.Println(f)
c.Status(200)
})
r.Run(":8082")
} |
any update regarding this? |
Description
I want to use a struct to bind map query parameter, it seems that gin doesn't support it yet.
How to reproduce
Run server:
Curl:
Environment
The text was updated successfully, but these errors were encountered: