aboutsummaryrefslogtreecommitdiff
path: root/src/modules/api/sydney.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-06-17 07:36:42 -0700
committerFuwn <[email protected]>2024-06-17 07:36:42 -0700
commitdd67bcf487e17b58435d712e49fa7e7b9bc2a408 (patch)
treed38c4f71ac5b01a48d83c4d85c30e650ffe36a78 /src/modules/api/sydney.rs
parentfeat(useful): update content (diff)
downloadlocus-dd67bcf487e17b58435d712e49fa7e7b9bc2a408.tar.xz
locus-dd67bcf487e17b58435d712e49fa7e7b9bc2a408.zip
build: nix flake
Diffstat (limited to 'src/modules/api/sydney.rs')
-rw-r--r--src/modules/api/sydney.rs46
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()
},
);
}