You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
759 B

package response
// Envelope for response objects
type Envelope struct {
Success bool `json:"success"`
RequestID string `json:"request_id,omitempty"`
Warnings []string `json:"warnings,omitempty"`
Errors []string `json:"errors,omitempty"`
// PaginationInfo *pagination.Pagination `json:"pagination_info,omitempty"`
Result interface{} `json:"result,omitempty"`
}
// AppendError to envelope
func (envelope *Envelope) AppendError(err error) *Envelope {
envelope.Success = false
envelope.Result = nil
envelope.Errors = append(envelope.Errors, err.Error())
return envelope
}
// SetSuccess to envelope
func (envelope *Envelope) SetSuccess(result interface{}) *Envelope {
envelope.Success = true
envelope.Result = result
return envelope
}