aboutsummaryrefslogtreecommitdiff
path: root/src/modules/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/api')
-rw-r--r--src/modules/api/sydney.rs51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/modules/api/sydney.rs b/src/modules/api/sydney.rs
index 20f8faa..e66f91d 100644
--- a/src/modules/api/sydney.rs
+++ b/src/modules/api/sydney.rs
@@ -27,34 +27,37 @@ pub fn module(router: &mut windmark::Router) {
"/api/sydney/version",
"Sydney's version",
move |context| {
- let mut content = "0.0.0".to_string();
-
- if let Ok(response) = reqwest::blocking::Client::new()
- .get("https://api.github.com/repos/gemrest/sydney/tags")
- .header(
- "User-Agent",
- format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")),
- )
- .send()
- {
- if let Ok(response_content) = response.json::<Vec<Tags>>() {
- let response_content: Vec<Tags> = response_content;
-
- if let Some(first_tag) = response_content.get(0) {
- content = first_tag.name().clone();
- }
-
- if let Some(just_tag) = content.get(1..) {
- content = just_tag.to_string();
+ 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 Some(first_tag) = response_content.get(0) {
+ content = first_tag.name().clone();
+ }
+
+ if let Some(just_tag) = content.get(1..) {
+ content = just_tag.to_string();
+ }
}
}
- }
- crate::route::cache(&context, &content);
+ crate::route::cache(&context, &content);
- windmark::Response::success(content)
- .with_mime("text/plain")
- .clone()
+ windmark::Response::success(content)
+ .with_mime("text/plain")
+ .clone()
+ }
},
);
}