diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-08-31 14:06:49 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-08-31 14:06:49 +0200 |
commit | 1d21195bd955d01f8ece8f963e905e8a21c524e3 (patch) | |
tree | a5addb8a3e34a21692c1961fab70ca3a9ad1f4c3 /client/go/util | |
parent | 91ec503c1e4bc577a1a4e051a776c5f3eda07d09 (diff) |
Extract document API
Diffstat (limited to 'client/go/util')
-rw-r--r-- | client/go/util/operationResult.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/client/go/util/operationResult.go b/client/go/util/operationResult.go new file mode 100644 index 00000000000..f2eaca3c03b --- /dev/null +++ b/client/go/util/operationResult.go @@ -0,0 +1,32 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// A struct containing the result of an operation +// Author: bratseth + +package util + +type OperationResult struct { + Success bool + Message string // Mandatory message + Detail string // Optional detail message + Payload string // Optional payload - may be present whether or not the operation was success +} + +func Success(message string) *OperationResult { + return &OperationResult{Success: true, Message: message} +} + +func SuccessWithPayload(message string, payload string) *OperationResult { + return &OperationResult{Success: true, Message: message, Payload: payload} +} + +func Failure(message string) *OperationResult { + return &OperationResult{Success: false, Message: message} +} + +func FailureWithPayload(message string, payload string) *OperationResult { + return &OperationResult{Success: false, Message: message, Payload: payload} +} + +func FailureWithDetail(message string, detail string) *OperationResult { + return &OperationResult{Success: false, Message: message, Detail: detail} +} |