Skip to content

Commit

Permalink
fix: missing baseResponse in Accepted helper (#1126)
Browse files Browse the repository at this point in the history
Co-authored-by: David Ragot <[email protected]>
  • Loading branch information
Dav-14 and David Ragot authored Jan 16, 2024
1 parent 49c3b42 commit 2ce2651
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions components/ledger/libs/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const (
defaultLimit = 15

ErrorCodeNotFound = "NOT_FOUND"
ErrorCodeAccepted = "ACCEPTED"
ErrorInternal = "INTERNAL"
)

Expand All @@ -27,10 +26,6 @@ func writeJSON(w http.ResponseWriter, statusCode int, v any) {
}
}

func Accepted(w http.ResponseWriter, v any) {
writeJSON(w, http.StatusAccepted, v)
}

func NotFound(w http.ResponseWriter, err error) {
writeJSON(w, http.StatusNotFound, ErrorResponse{
ErrorCode: ErrorCodeNotFound,
Expand Down Expand Up @@ -73,6 +68,11 @@ func InternalServerError(w http.ResponseWriter, r *http.Request, err error) {
})
}

func Accepted(w http.ResponseWriter, v any) {
writeJSON(w, http.StatusAccepted, BaseResponse[any]{
Data: &v,
})
}
func Created(w http.ResponseWriter, v any) {
writeJSON(w, http.StatusCreated, BaseResponse[any]{
Data: &v,
Expand Down
9 changes: 5 additions & 4 deletions libs/go-libs/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ func writeJSON(w http.ResponseWriter, statusCode int, v any) {
}
}

func Accepted(w http.ResponseWriter, v any) {
writeJSON(w, http.StatusAccepted, v)
}

func NotFound(w http.ResponseWriter, err error) {
writeJSON(w, http.StatusNotFound, ErrorResponse{
ErrorCode: ErrorCodeNotFound,
Expand Down Expand Up @@ -72,6 +68,11 @@ func InternalServerError(w http.ResponseWriter, r *http.Request, err error) {
})
}

func Accepted(w http.ResponseWriter, v any) {
writeJSON(w, http.StatusAccepted, BaseResponse[any]{
Data: &v,
})
}
func Created(w http.ResponseWriter, v any) {
writeJSON(w, http.StatusCreated, BaseResponse[any]{
Data: &v,
Expand Down

1 comment on commit 2ce2651

@vercel
Copy link

@vercel vercel bot commented on 2ce2651 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.