Feature Description
In my gin application, we have endpoints that depend on parameters located in more than one place: e.g. in the uri (POST /org/:id/user) and the body, assumed to be json. I'd like to bind those to a single go struct, like
type GetUsersParams {
orgId int
name string
role string
}
I want to be able to populate this single params struct with a single function call, looking for params in both URI and body (as json), regardless of whether each param is found in one place or the other, and assuming json regardless of whether the client passed content-type.
Unfortunately, we can't simply call shouldBindURI then shouldBindJSON, because each of those will return an error if ANY of the required GetUsersParams are absent from that particular location.
If I could call versions of these functions simply didn't call validate as their last step, and then called validate myself once at the end, this would be simple.
Feature Description
In my gin application, we have endpoints that depend on parameters located in more than one place: e.g. in the uri (
POST /org/:id/user) and the body, assumed to be json. I'd like to bind those to a single go struct, likeI want to be able to populate this single params struct with a single function call, looking for params in both URI and body (as json), regardless of whether each param is found in one place or the other, and assuming json regardless of whether the client passed
content-type.Unfortunately, we can't simply call
shouldBindURIthenshouldBindJSON, because each of those will return an error if ANY of therequiredGetUsersParams are absent from that particular location.If I could call versions of these functions simply didn't call
validateas their last step, and then calledvalidatemyself once at the end, this would be simple.