pub fn json_response<T: Serialize>(t: &T) -> Response {
    let json = serde_json::to_string(t).unwrap();
    let mut headers = HashMap::new();
    headers.insert(
        "Content-Type".to_string(),
        vec!["application/json; charset=utf-8".to_string()],
    );
    headers.insert("Content-Length".to_string(), vec![json.len().to_string()]);
    Response {
        status: (200, "OK"),
        headers,
        body: Box::new(Cursor::new(json.into_bytes())),
    }
}
/// Serialize a value to JSON and build a status 200 Response
///
/// This helper sets appropriate values for `Content-Type` and `Content-Length`.
///
/// # Panics
///
/// This function will panic if serialization fails.
Serialize a value to JSON and build a status 200 Response
This helper sets appropriate values for `Content-Type` and `Content-Length`.
Serialize a value to JSON and build a status 200 Response This helper sets appropriate values for ` Content - Type ` and ` Content - Length ` .
pub fn json_response<T: Serialize>(t: &T) -> Response {
    let json = serde_json::to_string(t).unwrap();
    let mut headers = HashMap::new();
    headers.insert(
        "Content-Type".to_string(),
        vec!["application/json; charset=utf-8".to_string()],
    );
    headers.insert("Content-Length".to_string(), vec![json.len().to_string()]);
    Response {
        status: (200, "OK"),
        headers,
        body: Box::new(Cursor::new(json.into_bytes())),
    }
}
pub fn json_response < T : Serialize > ( t : & T ) -> Response { let json = serde_json :: to_string ( t ) . unwrap ( ) ; let mut headers = HashMap :: new ( ) ; headers . insert ( " " . to_string ( ) , vec ! [ " " to_string ( ) ] , ) ; headers . insert ( " " . to_string ( ) , vec ! [ json len ( ) to_string ( ) ] ) ; Response { status : ( 200 , " " ) , headers , body : Box :: new ( Cursor :: new ( json . into_bytes ( ) ) ) , } }
Serialize a value to JSON and build a status 200 Response
This helper sets appropriate values for `Content-Type` and `Content-Length`.
Serialize a value to JSON and build a status 200 Response This helper sets appropriate values for ` Content - Type ` and ` Content - Length ` .
t
&T
panics
This function will panic if serialization fails.
This function will panic if serialization fails .