adding user authentication
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
use axum::Router;
|
||||
use axum::{
|
||||
routing::get,
|
||||
Router,
|
||||
response::Html,
|
||||
};
|
||||
use tower_http::services::ServeDir;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use crate::common::di::AppState;
|
||||
use crate::common::config::AppConfig;
|
||||
|
||||
/// Creates web routes for serving static files
|
||||
pub fn create_web_routes() -> Router {
|
||||
pub fn create_web_routes() -> Router<Arc<AppState>> {
|
||||
// Get config to access static path
|
||||
let config = AppConfig::from_env();
|
||||
let static_path = config.static_path.clone();
|
||||
|
||||
Router::new()
|
||||
// Add specific route for login
|
||||
.route("/login", get(serve_login_page))
|
||||
// Serve static files
|
||||
.fallback_service(
|
||||
ServeDir::new(PathBuf::from("static"))
|
||||
ServeDir::new(static_path)
|
||||
)
|
||||
}
|
||||
|
||||
/// Serve the login page
|
||||
async fn serve_login_page() -> Html<&'static str> {
|
||||
Html(include_str!("../../../static/login.html"))
|
||||
}
|
||||
Reference in New Issue
Block a user