chore: move around test_route

This commit is contained in:
əlemi 2024-12-03 01:24:02 +01:00
parent 64d53a5f51
commit 4cd67c3867
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -69,7 +69,7 @@ async fn entry(cli: Cli, config: Config, db: Database) -> Result<(), Box<dyn std
tokio::spawn(async move {
loop {
let res = test(&service.endpoint).await;
let res = test_route(&service.endpoint).await;
let value = match res {
Ok(rtt) => Some(rtt),
Err(e) => {
@ -98,6 +98,15 @@ async fn entry(cli: Cli, config: Config, db: Database) -> Result<(), Box<dyn std
Ok(())
}
async fn test_route(url: &str) -> reqwest::Result<i64> {
let before = chrono::Utc::now();
reqwest::get(url)
.await?
.error_for_status()?;
let delta = chrono::Utc::now() - before;
Ok(delta.num_milliseconds())
}
// ============= APIs
@ -129,15 +138,6 @@ async fn root() -> Html<&'static str> {
Html(include_str!("../index.html"))
}
async fn test(url: &str) -> reqwest::Result<i64> {
let before = chrono::Utc::now();
reqwest::get(url)
.await?
.error_for_status()?;
let delta = chrono::Utc::now() - before;
Ok(delta.num_milliseconds())
}
use axum::{extract::{Path, Query, State}, response::{Html, IntoResponse}, Json};
#[derive(serde::Deserialize)]