diff options
Diffstat (limited to 'src/modules/api/sydney.rs')
| -rw-r--r-- | src/modules/api/sydney.rs | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/src/modules/api/sydney.rs b/src/modules/api/sydney.rs index 037dccf..c67e54f 100644 --- a/src/modules/api/sydney.rs +++ b/src/modules/api/sydney.rs @@ -8,36 +8,34 @@ pub fn module(router: &mut windmark::router::Router) { router, "/api/sydney/version", "Sydney's version", - move |_context| { - async move { - let mut content = "0.0.0".to_string(); + move |_context| async move { + let mut content = "0.0.0".to_string(); - if let Ok(response) = reqwest::Client::new() - .get("https://api.github.com/repos/gemrest/sydney/tags") - .header( - "User-Agent", - format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")), - ) - .send() - .await - { - if let Ok(response_content) = response.json::<Vec<Tags>>().await { - let response_content: Vec<Tags> = response_content; + if let Ok(response) = reqwest::Client::new() + .get("https://api.github.com/repos/gemrest/sydney/tags") + .header( + "User-Agent", + format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")), + ) + .send() + .await + { + if let Ok(response_content) = response.json::<Vec<Tags>>().await { + let response_content: Vec<Tags> = response_content; - if let Some(first_tag) = response_content.first() { - content = first_tag.name().clone(); - } + if let Some(first_tag) = response_content.first() { + content.clone_from(first_tag.name()); + } - if let Some(just_tag) = content.get(1..) { - content = just_tag.to_string(); - } + if let Some(just_tag) = content.get(1..) { + content = just_tag.to_string(); } } - - windmark::response::Response::success(content) - .with_mime("text/plain") - .clone() } + + windmark::response::Response::success(content) + .with_mime("text/plain") + .clone() }, ); } |