Skip to content

Commit

Permalink
bugfix status code for created, updated and deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
setiadijoe committed Jul 1, 2021
1 parent f27c8d1 commit 99ba897
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions transport/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, response interfa
return nil
}
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)

status, ok := response.(*endpoint.StatusResponse)
if ok && status.Code != helper.STATUS_OK {
if ok {
if status.Code == helper.STATUS_CREATED {
w.WriteHeader(http.StatusCreated)
} else if status.Code == helper.STATUS_UPDATED || status.Code == helper.STATUS_DELETED {
w.WriteHeader(http.StatusNoContent)
_ = json.NewEncoder(w).Encode(nil)
return nil
} else {
w.WriteHeader(http.StatusOK)
}
}

Expand Down

0 comments on commit 99ba897

Please sign in to comment.