package controllers import ( "net/http" "github.com/gin-gonic/gin" ) // bindings are validated by https://github.com/go-playground/validator type StoreInput struct { RoleId int `json:"roleId"` DeviceName string `json:"deviceName" binding:"required"` UserName string `json:"userName" binding:"required"` SecretValue string `json:"secretValue" binding:"required"` } func Store(c *gin.Context) { var input RetrieveInput if err := c.ShouldBindJSON(&input); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } }