Skip to content

Commit

Permalink
feature: made it so that when the response is not successful and a me…
Browse files Browse the repository at this point in the history
…ssage is set then it's used as the error message to return
  • Loading branch information
akeemphilbert committed Aug 22, 2024
1 parent ef770a3 commit e8ff3db
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rest/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ func DefaultWriteController(p *ControllerParams) echo.HandlerFunc {
ctxt.Response().Header().Set("Location", response.Body.(string))
return ctxt.NoContent(response.Code)
}
if !response.Success {
if response.Body == nil {
return ctxt.JSON(response.Code, map[string]interface{}{
"message": response.Message,
})
}
}
return ctxt.JSON(response.Code, response.Body)
} else {
if err != nil {
Expand Down

0 comments on commit e8ff3db

Please sign in to comment.