mylloon.fr/src/main.rs
Mylloon c934d5f42e
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
better imports
2023-04-14 11:44:49 +02:00

49 lines
1.3 KiB
Rust

use actix_files::Files;
use actix_web::{middleware::DefaultHeaders, web, App, HttpServer};
use std::io::Result;
use crate::routes::{agreements, blog, contrib, index, networks, not_found, portfolio};
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.clone().fc.scheme.unwrap(),
addr.0,
addr.1
);
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(config.clone()))
.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::page)
.service(Files::new("/", config.static_location.clone()))
.default_service(web::to(not_found::page))
})
.bind(addr)?
.run()
.await
}