diff options
| author | Fuwn <[email protected]> | 2024-07-24 00:24:25 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-07-24 00:24:25 +0000 |
| commit | 28fbcfdeb2e93fbf3dc20731d3ef995935964637 (patch) | |
| tree | 3c32097cd572ab894f9e5bdb49343fd14a95a033 /src | |
| parent | fix(response): remove hard path fixer (diff) | |
| download | september-28fbcfdeb2e93fbf3dc20731d3ef995935964637.tar.xz september-28fbcfdeb2e93fbf3dc20731d3ef995935964637.zip | |
chore: remove semi-outdated technical information
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 14 | ||||
| -rw-r--r-- | src/response.rs | 10 | ||||
| -rw-r--r-- | src/url.rs | 2 |
3 files changed, 2 insertions, 24 deletions
diff --git a/src/main.rs b/src/main.rs index fd24088..9fe7910 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,34 +14,24 @@ mod html; mod response; mod url; -#[macro_use] extern crate log; +#[macro_use] +extern crate log; use {actix_web::web, response::default, std::env::var}; #[actix_web::main] async fn main() -> std::io::Result<()> { - // Set the `RUST_LOG` environment variable so Actix can provide logs. - // - // This can be overridden using the `RUST_LOG` environment variable in - // configuration. std::env::set_var("RUST_LOG", "actix_web=info"); - - // Initialise `dotenv` so we can access `.env` files. dotenv::dotenv().ok(); - // Initialise logger so we can see logs pretty_env_logger::init(); - // Setup Actix web-server actix_web::HttpServer::new(move || { actix_web::App::new() .default_service(web::get().to(default)) .wrap(actix_web::middleware::Logger::default()) }) .bind(( - // Bind Actix web-server to localhost "0.0.0.0", - // If the `PORT` environment variable is present, try to use it, otherwise; - // use port `80`. var("PORT").map_or(80, |port| match port.parse::<_>() { Ok(port) => port, Err(e) => { diff --git a/src/response.rs b/src/response.rs index 0159145..eceaa30 100644 --- a/src/response.rs +++ b/src/response.rs @@ -25,7 +25,6 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< let mut is_proxy = false; let mut is_raw = false; let mut is_nocss = false; - // Try to construct a Gemini URL let url = match url_from_path( &format!("{}{}", req.path(), { if !req.query_string().is_empty() || req.uri().to_string().ends_with('?') @@ -49,7 +48,6 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< ); } }; - // Make a request to get Gemini content and time it. let mut timer = Instant::now(); let mut response = match germ::request::request(&url).await { Ok(response) => response, @@ -94,10 +92,8 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< let language = meta.parameters().get("lang").map_or_else(String::new, ToString::to_string); - // Reset timer for below timer = Instant::now(); - // Convert Gemini Response to HTML and time it. let mut html_context = if is_raw { String::new() } else { @@ -137,8 +133,6 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< ); } - // Try to add an external stylesheet from the `CSS_EXTERNAL` environment - // variable. if let Ok(css) = var("CSS_EXTERNAL") { let stylesheets = css.split(',').filter(|s| !s.is_empty()).collect::<Vec<_>>(); @@ -160,8 +154,6 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< } } - // Try to add an external favicon from the `FAVICON_EXTERNAL` environment - // variable. if let Ok(favicon) = var("FAVICON_EXTERNAL") { html_context.push_str(&format!( "<link rel=\"icon\" type=\"image/x-icon\" href=\"{favicon}\">", @@ -182,7 +174,6 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< html_context.push_str(&head); } - // Add a title to HTML response html_context.push_str(&format!("<title>{gemini_title}</title>")); html_context.push_str("</head><body>"); @@ -216,7 +207,6 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".< _ => html_context.push_str(&format!("<p>{}</p>", response.meta())), } - // Add proxy information to footer of HTML response html_context.push_str(&format!( "<details>\n<summary>Proxy Information</summary> <dl> @@ -44,8 +44,6 @@ pub fn from_path( if fallback { "/" } else { "" } ) } else { - // Try to set `ROOT` as `ROOT` environment variable, or use - // `"gemini://fuwn.me"` as default. format!( "{}{}{}", { |