add index route

This commit is contained in:
Timofey Gelazoniya 2023-04-03 04:51:09 +03:00
parent d4ea5b55b9
commit 37137c3e84
Signed by: zeldon
GPG Key ID: 047886915281DD2A
3 changed files with 15 additions and 1 deletions

View File

@ -1,9 +1,10 @@
use axum::{extract::DefaultBodyLimit, routing::get, routing::post, Router}; 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 { pub fn create_router() -> Router {
Router::new() Router::new()
.route("/", get(index_route))
.route("/health", get(health_route)) .route("/health", get(health_route))
.route("/liquid", post(liquid_rescale_route)) .route("/liquid", post(liquid_rescale_route))
.layer(DefaultBodyLimit::max(1024 * 10_000 /* 10 MiB */)) .layer(DefaultBodyLimit::max(1024 * 10_000 /* 10 MiB */))

12
src/routes/index.rs Normal file
View File

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

View File

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