From 7a11c2eac11458293544f9e79daa1771b437131d Mon Sep 17 00:00:00 2001 From: David McNeil Date: Wed, 8 Aug 2018 11:11:15 -0600 Subject: [PATCH] Add json2 HttpResponseBuilder method --- src/httpresponse.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/httpresponse.rs b/src/httpresponse.rs index 2673da2a3..87bd8c8b8 100644 --- a/src/httpresponse.rs +++ b/src/httpresponse.rs @@ -650,7 +650,14 @@ impl HttpResponseBuilder { /// /// `HttpResponseBuilder` can not be used after this call. pub fn json(&mut self, value: T) -> HttpResponse { - match serde_json::to_string(&value) { + self.json2(&value) + } + + /// Set a json body and generate `HttpResponse` + /// + /// `HttpResponseBuilder` can not be used after this call. + pub fn json2(&mut self, value: &T) -> HttpResponse { + match serde_json::to_string(value) { Ok(body) => { let contains = if let Some(parts) = parts(&mut self.response, &self.err) {