-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
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
Metadata
Metadata
Assignees
Labels
No labels