mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
Add json2 HttpResponseBuilder method
This commit is contained in:
parent
8eb9eb4247
commit
7a11c2eac1
@ -650,7 +650,14 @@ impl HttpResponseBuilder {
|
||||
///
|
||||
/// `HttpResponseBuilder` can not be used after this call.
|
||||
pub fn json<T: Serialize>(&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<T: Serialize>(&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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user