From c419f923346b682bc6423a51bdbe61f7969b1594 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 16 Feb 2023 21:59:04 +0100 Subject: [PATCH] support onion --- src/config.rs | 2 ++ src/main.rs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index ec64f87..529af8d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,7 @@ pub struct Config { pub port: Option, pub mail: Option, pub lang: Option, + pub onion: Option, } 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), } } } diff --git a/src/main.rs b/src/main.rs index 54db691..7ad789a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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)