56 lines
1.5 KiB
Rust
56 lines
1.5 KiB
Rust
use actix_files::Files;
|
|
use actix_web::{middleware::DefaultHeaders, web, App, HttpServer};
|
|
use std::io::Result;
|
|
|
|
use crate::routes::{
|
|
agreements, blog, contrib, cours, cv, gaming, index, networks, not_found, portfolio, web3,
|
|
};
|
|
|
|
mod config;
|
|
mod template;
|
|
|
|
mod misc;
|
|
mod routes;
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> Result<()> {
|
|
let config = config::get_config("./config/config.toml");
|
|
|
|
let addr = ("0.0.0.0", config.fc.port.unwrap());
|
|
|
|
println!(
|
|
"Listening to {}://{}:{}",
|
|
config.to_owned().fc.scheme.unwrap(),
|
|
addr.0,
|
|
addr.1
|
|
);
|
|
|
|
HttpServer::new(move || {
|
|
App::new()
|
|
.app_data(web::Data::new(config.to_owned()))
|
|
.wrap(DefaultHeaders::new().add((
|
|
"Onion-Location",
|
|
config.fc.onion.as_deref().unwrap_or_default(),
|
|
)))
|
|
.service(index::page)
|
|
.service(agreements::security)
|
|
.service(agreements::humans)
|
|
.service(agreements::robots)
|
|
.service(agreements::sitemap)
|
|
.service(networks::page)
|
|
.service(portfolio::page)
|
|
.service(contrib::page)
|
|
.service(blog::index)
|
|
.service(blog::rss)
|
|
.service(blog::page)
|
|
.service(web3::page)
|
|
.service(gaming::page)
|
|
.service(cours::page)
|
|
.service(cv::page)
|
|
.service(Files::new("/", config.static_location.to_owned()))
|
|
.default_service(web::to(not_found::page))
|
|
})
|
|
.bind(addr)?
|
|
.run()
|
|
.await
|
|
}
|