aboutsummaryrefslogtreecommitdiffstats
path: root/api/dto/response.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/dto/response.go')
-rw-r--r--api/dto/response.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/api/dto/response.go b/api/dto/response.go
new file mode 100644
index 0000000..43f98bd
--- /dev/null
+++ b/api/dto/response.go
@@ -0,0 +1,21 @@
+package dto
+
+import "fmt"
+
+type OkResponse struct {
+ Code int `json:"code"`
+ Data interface{} `json:"data,omitempty"`
+}
+
+type ErrorResponse struct {
+ Code int `json:"code"`
+ Message string `json:"message"`
+}
+
+func (r *OkResponse) Error() string {
+ return fmt.Sprintf("HTTP status %d", r.Code)
+}
+
+func (r *ErrorResponse) Error() string {
+ return fmt.Sprintf("HTTP status %d: %s", r.Code, r.Message)
+}