aboutsummaryrefslogtreecommitdiffstats
path: root/git-lfs-authenticate/src
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-01-26 12:34:47 +0100
committerLibravatar Rutger Broekhoff2024-01-26 12:34:47 +0100
commitf033c6889e0071b29e75c551586e8e5da1b556a3 (patch)
tree7ab82ed0c11b6d4a1d45d3526015ecd631790be5 /git-lfs-authenticate/src
parentf146743061ba8170569bf18518202df9a43c09f3 (diff)
downloadgitolfs3-f033c6889e0071b29e75c551586e8e5da1b556a3.tar.gz
gitolfs3-f033c6889e0071b29e75c551586e8e5da1b556a3.zip
Use serde_json::json! instead of manually generating JSON
Diffstat (limited to 'git-lfs-authenticate/src')
-rw-r--r--git-lfs-authenticate/src/main.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/git-lfs-authenticate/src/main.rs b/git-lfs-authenticate/src/main.rs
index accc37f..3101c92 100644
--- a/git-lfs-authenticate/src/main.rs
+++ b/git-lfs-authenticate/src/main.rs
@@ -1,5 +1,6 @@
1use anyhow::{anyhow, bail, Result}; 1use anyhow::{anyhow, bail, Result};
2use chrono::Utc; 2use chrono::Utc;
3use serde_json::json;
3use std::{process::ExitCode, time::Duration}; 4use std::{process::ExitCode, time::Duration};
4 5
5fn main() -> ExitCode { 6fn main() -> ExitCode {
@@ -39,14 +40,17 @@ fn main() -> ExitCode {
39 return ExitCode::FAILURE; 40 return ExitCode::FAILURE;
40 }; 41 };
41 42
42 println!( 43 let response = json!({
43 "{{\"header\":{{\"Authorization\":\"Gitolfs3-Hmac-Sha256 {tag} {}\"}},\ 44 "header": {
44 \"expires_at\":\"{}\",\"href\":\"{}{}/info/lfs\"}}", 45 "Authorization": format!(
45 expires_at.timestamp(), 46 "Gitolfs3-Hmac-Sha256 {tag} {}",
46 common::EscJsonFmt(&expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true)), 47 expires_at.timestamp()
47 common::EscJsonFmt(&config.href_base), 48 ),
48 common::EscJsonFmt(&repo_name), 49 },
49 ); 50 "expires_at": expires_at.to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
51 "href": format!("{}{}/info/lfs", config.href_base, repo_name),
52 });
53 println!("{}", response.to_string());
50 54
51 ExitCode::SUCCESS 55 ExitCode::SUCCESS
52} 56}