|
|
@ -248,13 +248,18 @@ func (w *ResponseWriter) Error(err error) { |
|
|
|
if len(message) == 0 { |
|
|
|
if len(message) == 0 { |
|
|
|
message = http.StatusText(status) |
|
|
|
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) { |
|
|
|
func (w *ResponseWriter) Ok(data any, message ...string) { |
|
|
|
info := map[string]any{ |
|
|
|
info := map[string]any{ |
|
|
|
"code": 0, |
|
|
|
"code": 0, |
|
|
|
"message": "ok", |
|
|
|
"message": "ok", |
|
|
|
|
|
|
|
"success": true, |
|
|
|
"data": data, |
|
|
|
"data": data, |
|
|
|
} |
|
|
|
} |
|
|
|
if len(message) > 0 { |
|
|
|
if len(message) > 0 { |
|
|
|