We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
uri
json
Eg. for updateAccount API, How to bind uri and json for the same struct?
updateAccount
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
The text was updated successfully, but these errors were encountered:
I use result here: gin-gonic/gin#1824 (comment) but I wonder whether there is a better solution
Sorry, something went wrong.
No branches or pull requests
Eg. for
updateAccount
API, How to binduri
andjson
for the same struct?the code above does not work.
Does anyone know? Thanks in advance
The text was updated successfully, but these errors were encountered: