From 921a22e6456e12df5661742955df4f2af5fc05f3 Mon Sep 17 00:00:00 2001 From: Dmitri Date: Thu, 16 Apr 2026 09:44:52 +0200 Subject: [PATCH] splitted health on dedicated mod --- src/http/mod.rs | 1 + src/http/public.rs | 9 +++++++++ src/main.rs | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/http/mod.rs create mode 100644 src/http/public.rs diff --git a/src/http/mod.rs b/src/http/mod.rs new file mode 100644 index 0000000..86cbda1 --- /dev/null +++ b/src/http/mod.rs @@ -0,0 +1 @@ +pub mod public; diff --git a/src/http/public.rs b/src/http/public.rs new file mode 100644 index 0000000..01b4806 --- /dev/null +++ b/src/http/public.rs @@ -0,0 +1,9 @@ +use axum::{Router, routing::get}; + +pub fn router() -> Router { + Router::new().route("/health", get(get_health())) +} + +fn get_health() -> &'static str { + "{'status': 'ok'}" +} diff --git a/src/main.rs b/src/main.rs index 57661ce..afb8132 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,10 @@ -use axum::{Router, routing::get}; +mod http; + +use axum::Router; #[tokio::main] async fn main() { - let app = Router::new() - .route("/", get(|| async { "hello world" })) - .route("/health", get(|| async { "ok" })); + let app = Router::new().merge(http::public::router()); let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap(); axum::serve(listener, app).await.unwrap();