blob: 43142928d63bc814dc5df4cb1011d9d4d04d3a45 (
plain) (
tree)
|
|
use axum::{routing::get, Router};
use tutors::fs_tutor_repo::FsTutorRepo;
use std::sync::Arc;
use tower_http::services::ServeDir;
use posts::fs_post_repo::FsPostRepo;
mod helpers;
mod posts;
mod tutors;
mod views;
mod handlers;
#[tokio::main]
async fn main() {
let posts = Arc::new(FsPostRepo::with_dir(format!("/data/ct/{}", "blog")));
let tutors = Arc::new(FsTutorRepo::with_dir(format!("/data/ct/{}", "team")));
let app = Router::new()
.route("/", get(handlers::index_handler))
.route("/posts", get(handlers::posts_handler))
.route("/posts/:post_id", get(handlers::post_handler))
.with_state(posts)
.route("/policies", get(handlers::policies_handler))
.route("/brochure", get(handlers::brochure_handler))
.route("/about", get(handlers::about_handler))
.with_state(tutors)
.nest_service("/assets", ServeDir::new("/data/ct/assets"))
.nest_service("/team", ServeDir::new("/data/ct/team"))
.fallback_service(ServeDir::new("static"));
let listener = tokio::net::TcpListener::bind("0.0.0.0:8000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
|