support onion
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-02-16 21:59:04 +01:00
parent b0d1402431
commit c419f92334
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 7 additions and 1 deletions

View file

@ -7,6 +7,7 @@ pub struct Config {
pub port: Option<u16>,
pub mail: Option<String>,
pub lang: Option<String>,
pub onion: Option<String>,
}
impl Config {
@ -36,6 +37,7 @@ impl Config {
port: test(a.port, d.port),
mail: test(a.mail, d.mail),
lang: test(a.lang, d.lang),
onion: test(a.onion, d.onion),
}
}
}

View file

@ -1,5 +1,5 @@
use actix_files::Files;
use actix_web::{web, App, HttpServer};
use actix_web::{middleware::DefaultHeaders, web, App, HttpServer};
use glob::glob;
use minify_html::{minify, Cfg};
use std::{
@ -88,6 +88,10 @@ async fn main() -> io::Result<()> {
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(config.clone()))
.wrap(DefaultHeaders::new().add((
"Onion-Location",
config.onion.as_deref().unwrap_or_default(),
)))
.service(index::page)
.service(agreements::security)
.service(agreements::humans)