2025-03-20 09:22:31 +01:00
|
|
|
use crate::common::config::AppConfig;
|
2026-02-14 01:29:34 +01:00
|
|
|
use crate::common::di::AppState;
|
|
|
|
|
use axum::{Router, response::Html, routing::get};
|
|
|
|
|
use tower_http::services::ServeDir;
|
2025-03-17 21:28:08 +01:00
|
|
|
|
|
|
|
|
/// Creates web routes for serving static files
|
2025-03-24 16:47:42 +01:00
|
|
|
pub fn create_web_routes() -> Router<AppState> {
|
2025-03-20 09:22:31 +01:00
|
|
|
// Get config to access static path
|
|
|
|
|
let config = AppConfig::from_env();
|
|
|
|
|
let static_path = config.static_path.clone();
|
|
|
|
|
|
2025-03-17 21:28:08 +01:00
|
|
|
Router::new()
|
2026-02-13 22:44:20 +01:00
|
|
|
// Add specific routes for clean URLs (without .html)
|
2025-03-20 09:22:31 +01:00
|
|
|
.route("/login", get(serve_login_page))
|
2026-02-13 22:44:20 +01:00
|
|
|
.route("/profile", get(serve_profile_page))
|
|
|
|
|
.route("/admin", get(serve_admin_page))
|
|
|
|
|
.route("/shared", get(serve_shared_page))
|
2025-03-20 09:22:31 +01:00
|
|
|
// Serve static files
|
2026-02-14 01:29:34 +01:00
|
|
|
.fallback_service(ServeDir::new(static_path))
|
2025-03-20 09:22:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Serve the login page
|
|
|
|
|
async fn serve_login_page() -> Html<&'static str> {
|
|
|
|
|
Html(include_str!("../../../static/login.html"))
|
2026-02-13 22:44:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Serve the profile page
|
|
|
|
|
async fn serve_profile_page() -> Html<&'static str> {
|
|
|
|
|
Html(include_str!("../../../static/profile.html"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Serve the admin page
|
|
|
|
|
async fn serve_admin_page() -> Html<&'static str> {
|
|
|
|
|
Html(include_str!("../../../static/admin.html"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Serve the shared page
|
|
|
|
|
async fn serve_shared_page() -> Html<&'static str> {
|
|
|
|
|
Html(include_str!("../../../static/shared.html"))
|
2026-02-14 01:29:34 +01:00
|
|
|
}
|