2024-07-14 15:19:41 -04:00
|
|
|
use axum::http::StatusCode;
|
2024-07-14 15:14:52 -04:00
|
|
|
use axum::routing::get;
|
2024-07-14 15:19:41 -04:00
|
|
|
use axum::Json;
|
2024-07-14 15:14:52 -04:00
|
|
|
use axum::Router;
|
2024-07-14 15:19:41 -04:00
|
|
|
use serde::Serialize;
|
2024-07-14 15:14:52 -04:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
let app = Router::new().route("/health", get(health));
|
|
|
|
|
|
|
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
|
|
|
|
println!("Listening on port 8080. Pop open your browser to http://127.0.0.1:8080/ .");
|
|
|
|
axum::serve(listener, app).await?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2024-07-14 15:19:41 -04:00
|
|
|
async fn health() -> (StatusCode, Json<HealthResponse>) {
|
|
|
|
(StatusCode::OK, Json(HealthResponse { ok: true }))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
struct HealthResponse {
|
|
|
|
ok: bool,
|
2024-07-14 14:52:45 -04:00
|
|
|
}
|