chore: move around test_route
This commit is contained in:
parent
64d53a5f51
commit
4cd67c3867
1 changed files with 10 additions and 10 deletions
20
src/main.rs
20
src/main.rs
|
@ -69,7 +69,7 @@ async fn entry(cli: Cli, config: Config, db: Database) -> Result<(), Box<dyn std
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
let res = test(&service.endpoint).await;
|
let res = test_route(&service.endpoint).await;
|
||||||
let value = match res {
|
let value = match res {
|
||||||
Ok(rtt) => Some(rtt),
|
Ok(rtt) => Some(rtt),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -98,6 +98,15 @@ async fn entry(cli: Cli, config: Config, db: Database) -> Result<(), Box<dyn std
|
||||||
Ok(())
|
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
|
// ============= APIs
|
||||||
|
|
||||||
|
@ -129,15 +138,6 @@ async fn root() -> Html<&'static str> {
|
||||||
Html(include_str!("../index.html"))
|
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};
|
use axum::{extract::{Path, Query, State}, response::{Html, IntoResponse}, Json};
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
|
Loading…
Reference in a new issue