Skip to content

Commit

Permalink
Merge branch 'feature/255' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	controllers/rest/default_controllers.go
  • Loading branch information
akeemphilbert committed Apr 20, 2023
2 parents edc7d3d + 3b641b1 commit ab1ae9d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/rest/default_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func DefaultWriteController(api Container, commandDispatcher model.CommandDispat
},
}
commandResponse, err = commandDispatcher.Dispatch(ctxt.Request().Context(), command, api, entityRepository, ctxt.Logger())
//an error handler `HTTPErrorHandler` can be defined on the echo instance to handle error responses
if err != nil {
if derr, ok := err.(*model.DomainError); ok && derr.Code == 400 {
return ctxt.JSON(http.StatusBadRequest, commandResponse)
Expand All @@ -100,7 +101,12 @@ func DefaultWriteController(api Container, commandDispatcher model.CommandDispat
}
return ctxt.JSON(http.StatusCreated, commandResponse)
default:
return ctxt.JSON(http.StatusOK, commandResponse)
//check to see if the response is a map or string
if stringResponse, ok := commandResponse.(string); ok {
return ctxt.String(http.StatusOK, stringResponse)
} else {
return ctxt.JSON(http.StatusOK, commandResponse)
}
}
}
}
Expand Down

0 comments on commit ab1ae9d

Please sign in to comment.