-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Bind JSON and URI #1824
Comments
you should split bind uri and json to two struct. |
@thinkerou ok, I split it into two structs and used the respective binds: if err := c.ShouldBindUri(&dataURI); err != nil {
c.JSON(400, gin.H{"error": err})
return
}
if err := c.ShouldBindJSON(&dataJSON); err != nil {
c.JSON(400, gin.H{"error": err})
return
} That works fine and removes my workaround of using |
@thinkerou Why not use the uri and form tag together? I think it would be convenient. |
no, I want to use it in one struct |
At 2023, we still should split it into two structs? |
|
If you set Balance int64 |
Description
I'm trying to bind JSON and a URI in one request but havn't found out how to yet.
Here's my struct:
I'm using
c.Bind()
:When I make this request it says the code is required:
I found a related issue #811 but it wasn't actually solved before being closed.
The text was updated successfully, but these errors were encountered: