Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abaldeweg authored Oct 26, 2024
1 parent 11cafec commit dc07407
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gateway/core/controllers/author.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (ac *AuthorController) GetAuthors(c *gin.Context) {

authors, err := ac.repo.FindAllByTerm(term)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to receive author"})
return
}

Expand Down Expand Up @@ -62,12 +62,12 @@ func (ac *AuthorController) GetAuthor(c *gin.Context) {
func (ac *AuthorController) CreateAuthor(c *gin.Context) {
var author models.Author
if err := c.ShouldBindJSON(&author); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": "Bad Request"})
return
}

if err := ac.v.Struct(author); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": "Not Valid"})
return
}

Expand All @@ -89,14 +89,14 @@ func (ac *AuthorController) UpdateAuthor(c *gin.Context) {

var author models.Author
if err := c.ShouldBindJSON(&author); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": "Bad Request"})
return
}

author.ID = id

if err := ac.v.Struct(author); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
c.JSON(http.StatusBadRequest, gin.H{"error": "Not Valid"})
return
}

Expand Down

0 comments on commit dc07407

Please sign in to comment.