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 103f23c commit 611c5dbCopy full SHA for 611c5db
src/controllers/user/other.rs
@@ -16,11 +16,7 @@ pub fn show(req: &mut dyn RequestExt) -> EndpointResult {
16
.order(id.desc())
17
.first(&*conn)?;
18
19
- #[derive(Serialize)]
20
- struct R {
21
- user: EncodablePublicUser,
22
- }
23
- Ok(req.json(&R { user: user.into() }))
+ Ok(req.json(&json!({ "user": EncodablePublicUser::from(user) })))
24
}
25
26
/// Handles the `GET /users/:user_id/stats` route.
@@ -39,11 +35,5 @@ pub fn stats(req: &mut dyn RequestExt) -> EndpointResult {
39
35
.first::<Option<i64>>(&*conn)?
40
36
.unwrap_or(0);
41
37
42
43
44
- total_downloads: i64,
45
46
- Ok(req.json(&R {
47
- total_downloads: data,
48
- }))
38
+ Ok(req.json(&json!({ "total_downloads": data })))
49
0 commit comments