From fa864b89b2c93409fb8b3faf1adefb42950bfca5 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 21 Apr 2022 03:22:23 +0000 Subject: feat(proxy): create full html document --- src/main.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 795127e..ade91ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -313,25 +313,29 @@ async fn default(req: actix_web::HttpRequest) -> Result { timer = Instant::now(); // Convert Gemini Response to HTML and time it. - let mut html_context = gemini_to_html(&response, &url, is_proxy); + let mut html_context = String::from(""); + let gemini_html = gemini_to_html(&response, &url, is_proxy); + let gemini_title = gemini_html.0; let convert_time_taken = timer.elapsed(); // Try to add an external stylesheet from the `CSS_EXTERNAL` environment // variable. if let Ok(css) = var("CSS_EXTERNAL") { - html_context.1.push_str(&format!( + html_context.push_str(&format!( "", css )); } // Add a title to HTML response - html_context - .1 - .push_str(&format!("{}", html_context.0)); + html_context.push_str(&format!("{}", gemini_title)); + + html_context.push_str(""); + + html_context.push_str(&gemini_html.1); // Add proxy information to footer of HTML response - html_context.1.push_str(&format!( + html_context.push_str(&format!( "
\nProxy information
Original URL
@@ -347,7 +351,7 @@ async fn default(req: actix_web::HttpRequest) -> Result {

This content has been proxied by \ September ({}).

-
", +", url, response.status, response.meta, @@ -361,7 +365,7 @@ async fn default(req: actix_web::HttpRequest) -> Result { Ok( HttpResponse::Ok() .content_type("text/html; charset=utf-8") - .body(html_context.1), + .body(html_context), ) } -- cgit v1.2.3