feat: fixup "add a DEBUG page to the UI with a database usage example"

This commit is contained in:
2024-09-24 15:46:53 +02:00
parent 777b7f2425
commit 90e79c1fa4
8 changed files with 69 additions and 4 deletions

View File

@ -7,6 +7,7 @@ use thiserror::Error;
use ::utils::config::{load_config, ConfigError};
mod api;
mod db;
#[derive(Error, Debug)]
@ -27,10 +28,13 @@ pub struct AppState {
pub async fn get_router() -> Result<Router, DbErr> {
let db_connection = db::get_connection().await?;
let state: AppState = AppState { db_connection };
Ok(Router::new()
.route("/", get(|| async { "Hello, world!" }))
.fallback(fallback))
.merge(api::get_routes())
.fallback(fallback)
.with_state(state))
}
async fn fallback(uri: Uri) -> (StatusCode, String) {