mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 02:18:25 +00:00
27 lines
781 B
Rust
27 lines
781 B
Rust
use crate::config::HttpConfig;
|
|
use clap::Parser;
|
|
use http::Method;
|
|
|
|
#[derive(Parser, Debug, Default)]
|
|
pub struct HealthArgs {}
|
|
|
|
/// Healthcheck for running rustical instance
|
|
/// Currently just pings to see if it's reachable via HTTP
|
|
#[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
|
pub async fn cmd_health(http_config: HttpConfig, _health_args: HealthArgs) -> anyhow::Result<()> {
|
|
let client = reqwest::ClientBuilder::new().build().unwrap();
|
|
|
|
let endpoint = format!(
|
|
"http://{host}:{port}/ping",
|
|
host = http_config.host,
|
|
port = http_config.port
|
|
)
|
|
.parse()
|
|
.unwrap();
|
|
let request = reqwest::Request::new(Method::GET, endpoint);
|
|
|
|
assert!(client.execute(request).await.unwrap().status().is_success());
|
|
|
|
Ok(())
|
|
}
|