refactor: move route definitions to a separate module
This commit is contained in:
26
libertas_api/src/routes.rs
Normal file
26
libertas_api/src/routes.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use axum::{
|
||||
Router,
|
||||
routing::{get, post},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
handlers::{album_handlers, auth_handlers, media_handlers},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
pub fn api_routes() -> Router<AppState> {
|
||||
let auth_routes = Router::new()
|
||||
.route("/register", post(auth_handlers::register))
|
||||
.route("/login", post(auth_handlers::login));
|
||||
|
||||
let user_routes = Router::new().route("/me", get(auth_handlers::get_me));
|
||||
let media_routes = media_handlers::media_routes();
|
||||
let album_routes = album_handlers::album_routes();
|
||||
|
||||
Router::new()
|
||||
.route("/api/v1/health", get(|| async { "OK" }))
|
||||
.nest("/api/v1/auth", auth_routes)
|
||||
.nest("/api/v1/users", user_routes)
|
||||
.nest("/api/v1/media", media_routes)
|
||||
.nest("/api/v1/albums", album_routes)
|
||||
}
|
||||
Reference in New Issue
Block a user