Files
Oxicloud/src/interfaces/web/mod.rs
T

30 lines
791 B
Rust
Raw Normal View History

2025-03-20 09:22:31 +01:00
use axum::{
routing::get,
Router,
response::Html,
};
2025-03-17 21:28:08 +01:00
use tower_http::services::ServeDir;
use std::path::PathBuf;
2025-03-20 09:22:31 +01:00
use std::sync::Arc;
use crate::common::di::AppState;
use crate::common::config::AppConfig;
2025-03-17 21:28:08 +01:00
/// Creates web routes for serving static files
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()
2025-03-20 09:22:31 +01:00
// Add specific route for login
.route("/login", get(serve_login_page))
// Serve static files
2025-03-17 21:28:08 +01:00
.fallback_service(
2025-03-20 09:22:31 +01:00
ServeDir::new(static_path)
2025-03-17 21:28:08 +01:00
)
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"))
2025-03-17 21:28:08 +01:00
}