add health route

This commit is contained in:
Timofey Gelazoniya 2023-04-03 04:47:53 +03:00
parent 573261911d
commit d4ea5b55b9
Signed by: zeldon
GPG Key ID: 047886915281DD2A
5 changed files with 15 additions and 2 deletions

1
Cargo.lock generated
View File

@ -443,6 +443,7 @@ dependencies = [
"log",
"magick_rust",
"serde",
"serde_json",
"tokio",
]

View File

@ -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"]}

View File

@ -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 */))
}

9
src/routes/health.rs Normal file
View File

@ -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"
}))
}

View File

@ -1 +1,2 @@
pub mod health;
pub mod liquid;