Skip to content

Commit

Permalink
update response package
Browse files Browse the repository at this point in the history
  • Loading branch information
Titus Silver committed May 29, 2022
1 parent 2e0d56c commit a50b438
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ func (svc *SuccessResponse) IsError() bool {
return false
}

func NewErrorBuilder(msg string, status int) ValidResponse {
svc := ErrorResponse{}
svc.ErrorMessage = msg
svc.ErrorStatus = http.StatusInternalServerError
return &svc
}

func NewSuccessBuilder(msg string) ValidResponse {
svc := SuccessResponse{}
svc.Message = msg
return &svc
}

// Success() - returns success response
func Success(w http.ResponseWriter, payload interface{}) {
result, err := json.Marshal(payload)
Expand Down

0 comments on commit a50b438

Please sign in to comment.