diff --git a/Cargo.lock b/Cargo.lock index 192991d..4c4a9f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -443,6 +443,7 @@ dependencies = [ "log", "magick_rust", "serde", + "serde_json", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 35cda95..bac1b71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,5 @@ env_logger = "0.10.0" log = "0.4.17" magick_rust = "0.17.0" serde = { version = "1.0.159", features = ["derive"] } +serde_json = "1.0.95" tokio = {version = "1", features = ["macros", "rt-multi-thread"]} diff --git a/src/router.rs b/src/router.rs index 078fb8b..11142fc 100644 --- a/src/router.rs +++ b/src/router.rs @@ -1,9 +1,10 @@ -use axum::{extract::DefaultBodyLimit, routing::post, Router}; +use axum::{extract::DefaultBodyLimit, routing::get, routing::post, Router}; -use crate::routes::liquid::liquid_rescale_route; +use crate::routes::{health::health_route, liquid::liquid_rescale_route}; pub fn create_router() -> Router { Router::new() + .route("/health", get(health_route)) .route("/liquid", post(liquid_rescale_route)) .layer(DefaultBodyLimit::max(1024 * 10_000 /* 10 MiB */)) } diff --git a/src/routes/health.rs b/src/routes/health.rs new file mode 100644 index 0000000..c949760 --- /dev/null +++ b/src/routes/health.rs @@ -0,0 +1,9 @@ +use axum::{response::IntoResponse, Json}; +use serde_json::json; + +pub async fn health_route() -> impl IntoResponse { + Json(json!({ + "ready": true, + "reason": "Everything is OK" + })) +} diff --git a/src/routes/mod.rs b/src/routes/mod.rs index cd5d61a..ad7df36 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1 +1,2 @@ +pub mod health; pub mod liquid;