json_response

Macro json_response 

Source
macro_rules! json_response {
    ($($json:tt)+) => { ... };
}
Expand description

Creates a JSON response directly from a JSON literal. Returns Ok(HttpResponse) for use as Response type.

§Examples

json_response!({
    "users": [{"id": 1, "name": "John"}]
})

// With status code (chain on the Result)
json_response!({"error": "Not found"}).map(|r| r.status(404))