json health.

This commit is contained in:
Tom Alexander
2024-07-14 15:19:41 -04:00
parent 02e288ef31
commit 82a5f145e1
3 changed files with 42 additions and 3 deletions

View File

@@ -1,5 +1,8 @@
use axum::http::StatusCode;
use axum::routing::get;
use axum::Json;
use axum::Router;
use serde::Serialize;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -11,6 +14,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
async fn health() -> &'static str {
"ok"
async fn health() -> (StatusCode, Json<HealthResponse>) {
(StatusCode::OK, Json(HealthResponse { ok: true }))
}
#[derive(Serialize)]
struct HealthResponse {
ok: bool,
}