From 963d4aabf37b2413830fb1c3050c609f3466a1f8 Mon Sep 17 00:00:00 2001 From: hupeh Date: Tue, 3 Jan 2023 02:15:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20:recycle:=20=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E4=BD=93=E4=B8=AD=E6=B7=BB=E5=8A=A0=20success=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/net.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/net.go b/app/net.go index f4432fc..b3e86b4 100644 --- a/app/net.go +++ b/app/net.go @@ -248,13 +248,18 @@ func (w *ResponseWriter) Error(err error) { if len(message) == 0 { message = http.StatusText(status) } - w.Send(status, map[string]any{"code": code, "message": message}) + w.Send(status, map[string]any{ + "code": code, + "message": message, + "success": code == 0, + }) } func (w *ResponseWriter) Ok(data any, message ...string) { info := map[string]any{ "code": 0, "message": "ok", + "success": true, "data": data, } if len(message) > 0 {