aboutsummaryrefslogtreecommitdiffstats
path: root/api/dto/response.go
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2025-01-17 13:21:24 +0000
committerLeonardo Bishop <me@leonardobishop.com>2025-01-17 13:21:24 +0000
commitc00b690bd6f600554a1404e692bd9e4373325d27 (patch)
tree4488b625e1c24af52fced6f60ac1b3ddff1383bc /api/dto/response.go
Initial commit
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)
+}