httpin
httpin copied to clipboard
Allow mix of body input and param input
Due to this check and potentially missing implementation, a mix of JSON/XML bodies along with other directives is not possible.
This blocks common REST calls, for example creating/updating entities (POST /entity/:id
/PUT /entity/:id
), where you wish to decode both the URL param :id
and the incoming JSON body into a single struct.
Hi @snicol , actually httpin does support mixing body input and param input currently. We can use the body directive along with other param input related directives. Let's see an example:
type UpdateUserInput struct {
ID string `in:"path=id"` // NOTE: register a path directive before using
Payload struct {
Display string `json:"display"`
Email string `json:"email"`
IsAdmin bool `json:"is_admin"`
} `in:"body=json"`
}
Please checkout a runable demo here https://go.dev/play/p/kDHljK4PbGF
So, the problem here is that the Body Annotations don't support a mix. I think it's okay now, I will update the docs and make it more clear. Thanks for the report :)