Skip to content

Commit da9c91d

Browse files
committed
controllers::site_metadata: Use json! macro to simplify JSON serialization code
1 parent c010a0d commit da9c91d

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/controllers/site_metadata.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ pub fn show_deployed_sha(req: &mut dyn RequestExt) -> EndpointResult {
88
let deployed_sha =
99
dotenv::var("HEROKU_SLUG_COMMIT").unwrap_or_else(|_| String::from("unknown"));
1010

11-
#[derive(Serialize)]
12-
struct R<'a> {
13-
deployed_sha: &'a str,
14-
commit: &'a str,
15-
}
16-
Ok(req.json(&R {
17-
deployed_sha: &deployed_sha[..],
18-
commit: &deployed_sha[..],
19-
}))
11+
Ok(req.json(&json!({
12+
"deployed_sha": &deployed_sha[..],
13+
"commit": &deployed_sha[..],
14+
})))
2015
}

0 commit comments

Comments
 (0)