mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 21:16:31 +00:00
27 lines
610 B
Go
27 lines
610 B
Go
package server
|
|
|
|
type Result struct {
|
|
Error bool `json:"error,omitempty"`
|
|
Details interface{} `json:"details,omitempty"`
|
|
Message string `json:"message,omitempty"`
|
|
Item interface{} `json:"item,omitempty"`
|
|
}
|
|
|
|
// Wrap creates a Wrapper instance and adds the initial namespace and data to be returned.
|
|
func Wrap(data interface{}) Result {
|
|
return Result{
|
|
Item: data,
|
|
}
|
|
}
|
|
|
|
func (r Result) AddMessage(message string) Result {
|
|
r.Message = message
|
|
return r
|
|
}
|
|
|
|
func (r Result) AddError(err string, details interface{}) Result {
|
|
r.Message = err
|
|
r.Details = details
|
|
r.Error = true
|
|
return r
|
|
}
|