Skip to content
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

Binding URI and JSON on the same struct #2758

Open
tunhuit opened this issue Jun 23, 2021 · 2 comments
Open

Binding URI and JSON on the same struct #2758

tunhuit opened this issue Jun 23, 2021 · 2 comments

Comments

@tunhuit
Copy link

tunhuit commented Jun 23, 2021

I want to bind URI params and JSON payload in the same struct, How can I do this?

type UpdateRequest struct {
    ID   uint64 `uri:"id" binding:"required"`
    Data struct {
        Name string `json:"name" binding:"required"`
        Slug string `json:"slug" binding:"required"`
    }
}
@masterZSH
Copy link

`

	var params UpdateRequest

	c.ShouldBindUri(&params)

	c.ShouldBindJSON(&params.Data)

`

@kszafran
Copy link
Contributor

kszafran commented Aug 5, 2021

Related PR: #2812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants