mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
Handles bindJSON error in addUser endpoint
This commit is contained in:
parent
c1fcf7e0c0
commit
f805bf1b33
1 changed files with 6 additions and 3 deletions
|
@ -166,9 +166,12 @@ func addUser(c *gin.Context) {
|
|||
|
||||
// Bind the response (context) with the User struct
|
||||
var newUser User
|
||||
if err := c.BindJSON(&newUser); err != nil {
|
||||
// TODO: do something other than panic ...
|
||||
panic(err)
|
||||
if err := c.ShouldBindJSON(&newUser); err != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, gin.H{
|
||||
"success": false,
|
||||
"message": fmt.Sprintf("%v", err),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: validate the User for:
|
||||
|
|
Loading…
Add table
Reference in a new issue