This commit is contained in:
2024-10-13 01:21:13 +08:00
parent 915d3f3716
commit 18e4a8080d
6 changed files with 48 additions and 20 deletions

View File

@@ -44,15 +44,10 @@ func sendResponse(ctx context.Context, w http.ResponseWriter, code int, message
// 响应成功
func Success(ctx context.Context, w http.ResponseWriter, data interface{}) {
ctx = context.WithValue(ctx, "status", "success")
ctx = context.WithValue(ctx, "Charges", true)
sendResponse(ctx, w, 0, "success", data)
}
// 响应失败
func Fail(ctx context.Context, w http.ResponseWriter, err *errs.AppError) {
ctx = context.WithValue(ctx, "status", "failed")
ctx = context.WithValue(ctx, "remark", err.Message)
sendResponse(ctx, w, err.Code, err.Message, nil)
}