Skip to main content

json

Function json 

Source
pub fn json<T: Serialize>(
    status: StatusCode,
    value: &T,
) -> Result<Response<ResponseBody>, ServeError>
Expand description

Build a JSON response with the given status code and serializable value.

Sets Content-Type: application/json and Content-Length headers. Returns 500 Internal Server Error if serialization fails.