Skip to content

Commit

Permalink
fix: handler pass by ref
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jan 9, 2024
1 parent e31bf92 commit 81b3501
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/app/handler/user/user.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewHandler(service user.Service, validate validator.IDtoValidator) *Handler
func (h *Handler) FindOne(c router.IContext) {
id, err := c.ID()
if err != nil {
c.JSON(http.StatusBadRequest, dto.ResponseErr{
c.JSON(http.StatusBadRequest, &dto.ResponseErr{
StatusCode: http.StatusBadRequest,
Message: err.Error(),
Data: nil,
Expand All @@ -50,7 +50,7 @@ func (h *Handler) FindOne(c router.IContext) {
return
}

c.JSON(http.StatusCreated, dto.ResponseSuccess{
c.JSON(http.StatusOK, &dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: userconst.FindOneUserSuccessMessage,
Data: user,
Expand All @@ -77,7 +77,7 @@ func (h *Handler) Update(c router.IContext) {

err := c.Bind(request)
if err != nil {
c.JSON(http.StatusBadRequest, dto.ResponseErr{
c.JSON(http.StatusBadRequest, &dto.ResponseErr{
StatusCode: http.StatusBadRequest,
Message: constant.BindingRequestErrorMessage + err.Error(),
Data: nil,
Expand All @@ -90,7 +90,7 @@ func (h *Handler) Update(c router.IContext) {
for _, reqErr := range err {
errorMessage = append(errorMessage, reqErr.Message)
}
c.JSON(http.StatusBadRequest, dto.ResponseErr{
c.JSON(http.StatusBadRequest, &dto.ResponseErr{
StatusCode: http.StatusBadRequest,
Message: constant.InvalidRequestBodyMessage + strings.Join(errorMessage, ", "),
Data: nil,
Expand All @@ -104,7 +104,7 @@ func (h *Handler) Update(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
c.JSON(http.StatusOK, &dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: userconst.UpdateUserSuccessMessage,
Data: user,
Expand All @@ -128,7 +128,7 @@ func (h *Handler) Update(c router.IContext) {
func (h *Handler) Delete(c router.IContext) {
id, err := c.ID()
if err != nil {
c.JSON(http.StatusBadRequest, dto.ResponseErr{
c.JSON(http.StatusBadRequest, &dto.ResponseErr{
StatusCode: http.StatusBadRequest,
Message: err.Error(),
Data: nil,
Expand All @@ -142,7 +142,7 @@ func (h *Handler) Delete(c router.IContext) {
return
}

c.JSON(http.StatusOK, dto.ResponseSuccess{
c.JSON(http.StatusOK, &dto.ResponseSuccess{
StatusCode: http.StatusOK,
Message: userconst.DeleteUserSuccessMessage,
Data: res,
Expand Down

0 comments on commit 81b3501

Please sign in to comment.