blob: c67e54ff7d3811f9c18f932e86c86eb55c3a10c6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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::<Vec<Tags>>().await {
let response_content: Vec<Tags> = 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()
},
);
}
|