mod commit; mod tags; use tags::Tags; pub fn module(router: &mut windmark::router::Router) { crate::route::track_mount( router, "/api/sydney/version", "Sydney's version", 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::>().await { let response_content: Vec = response_content; 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(); } } } windmark::response::Response::success(content) .with_mime("text/plain") .clone() }, ); }