use crate::http::response::IntoResponse;
use crate::http::routing::get;
use crate::http::Router;
use std::sync::OnceLock;
use std::time::SystemTime;
static BOOT_TIME: OnceLock<u64> = OnceLock::new();
fn boot_time() -> u64 {
*BOOT_TIME.get_or_init(|| {
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap_or_default()
.as_millis() as u64
})
}
pub fn dev_routes<T: Clone + Send + Sync + 'static>() -> Router<T> {
Router::new()
.route("/__quarlus_dev/status", get(status_handler))
.route("/__quarlus_dev/ping", get(ping_handler))
}
async fn status_handler() -> impl IntoResponse {
"dev"
}
async fn ping_handler() -> impl IntoResponse {
let ts = boot_time();
serde_json::json!({ "boot_time": ts, "status": "ok" }).to_string()
}