diff --git a/response.go b/response.go index ea27e27..8d90b86 100644 --- a/response.go +++ b/response.go @@ -129,13 +129,13 @@ func ResponseCtx(ctx context.Context, w http.ResponseWriter, ops ...Option) { } } + bs, _ := json.Marshal(resp) + if !def.ignoreLog { // 记录日志 - def.logger.Info(ctx, "response:", resp) + def.logger.Info(ctx, "response:", string(bs)) } - bs, _ := json.Marshal(resp) - w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(200) n, err := w.Write(bs)