We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
json!
1 parent f8ab731 commit da37e26Copy full SHA for da37e26
src/util/errors/json.rs
@@ -8,18 +8,9 @@ use conduit::{header, StatusCode};
8
9
/// Generates a response with the provided status and description as JSON
10
fn json_error(detail: &str, status: StatusCode) -> AppResponse {
11
- #[derive(Serialize)]
12
- struct StringError<'a> {
13
- detail: &'a str,
14
- }
15
16
- struct Bad<'a> {
17
- errors: [StringError<'a>; 1],
18
+ let json = json!({ "errors": [{ "detail": detail }] });
19
20
- let mut response = json_response(&Bad {
21
- errors: [StringError { detail }],
22
- });
+ let mut response = json_response(&json);
23
*response.status_mut() = status;
24
response
25
}
0 commit comments