Eg. for updateAccount API, How to bind uri and json for the same struct?
type updateAccountRequest struct {
ID int64 `uri:"id" binding:"required,min=1"`
Currency string `json:"currency" binding:"required,currency"`
}
func (server *Server) updateArticle(ctx *gin.Context) {
var req updateAccountRequest
if err := ctx.ShouldBindUri(&req); err != nil {
// send 400 Bad Request to the client
ctx.JSON(http.StatusBadRequest, errorResponse(err))
return
}
if err := ctx.ShouldBindJSON(&req); err != nil {
// send 400 Bad Request to the client
ctx.JSON(http.StatusBadRequest, errorResponse(err))
return
}
}
the code above does not work.
Does anyone know? Thanks in advance
Eg. for
updateAccountAPI, How to binduriandjsonfor the same struct?the code above does not work.
Does anyone know? Thanks in advance