From 37137c3e84b14542edb7b5f019ab14a1be6cdedf Mon Sep 17 00:00:00 2001 From: xzeldon Date: Mon, 3 Apr 2023 04:51:09 +0300 Subject: [PATCH] add index route --- src/router.rs | 3 ++- src/routes/index.rs | 12 ++++++++++++ src/routes/mod.rs | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/routes/index.rs diff --git a/src/router.rs b/src/router.rs index 11142fc..edd61d0 100644 --- a/src/router.rs +++ b/src/router.rs @@ -1,9 +1,10 @@ use axum::{extract::DefaultBodyLimit, routing::get, routing::post, Router}; -use crate::routes::{health::health_route, liquid::liquid_rescale_route}; +use crate::routes::{health::health_route, index::index_route, liquid::liquid_rescale_route}; pub fn create_router() -> Router { Router::new() + .route("/", get(index_route)) .route("/health", get(health_route)) .route("/liquid", post(liquid_rescale_route)) .layer(DefaultBodyLimit::max(1024 * 10_000 /* 10 MiB */)) diff --git a/src/routes/index.rs b/src/routes/index.rs new file mode 100644 index 0000000..c58e2b9 --- /dev/null +++ b/src/routes/index.rs @@ -0,0 +1,12 @@ +use axum::{response::IntoResponse, Json}; +use serde_json::json; + +pub async fn index_route() -> impl IntoResponse { + let data = json!({ + "name": "liquid-rescale-api", + "version": env!("CARGO_PKG_VERSION"), + "about": "Welcome traveler!" + }); + + Json(data) +} diff --git a/src/routes/mod.rs b/src/routes/mod.rs index ad7df36..773dba7 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,2 +1,3 @@ pub mod health; +pub mod index; pub mod liquid;