(refactor) more clean architecture
This commit is contained in:
parent
0a45d6e139
commit
8a03bdee96
8 changed files with 278 additions and 53 deletions
24
src/route.rs
Normal file
24
src/route.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// src/route.rs
|
||||
// Почему это здесь?
|
||||
// - Это центр управления всеми HTTP маршрутами (роутами)
|
||||
// - Здесь объявляются все подмодули (handlers, будущие сервисы и т.д.)
|
||||
// - Здесь собирается финальный Router для Axum
|
||||
|
||||
pub mod handlers; // Объявляем подмодуль handlers
|
||||
|
||||
use axum::{routing::get, Router};
|
||||
use crate::AppState;
|
||||
|
||||
/// Создаёт и возвращает Router со всеми сконфигурированными роутами
|
||||
/// Функция принимает AppState и передаёт его всем handlers'ам
|
||||
pub fn router(app_state: AppState) -> Router {
|
||||
Router::new()
|
||||
// GET /api/health — health-check эндпоинт
|
||||
.route("/api/health", get(handlers::health_handler))
|
||||
|
||||
// Сюда добавим новые роуты по мере разработки:
|
||||
// .route("/api/accounts", get(handlers::accounts::get_accounts))
|
||||
// .route("/api/payments", post(handlers::payments::create_payment))
|
||||
|
||||
.with_state(app_state)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue