mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-27 21:00:28 +00:00
Initial commit
This commit is contained in:
commit
29f583e936
135 changed files with 18463 additions and 0 deletions
27
backend/pkgs/server/result.go
Normal file
27
backend/pkgs/server/result.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue