Skip to content

Commit

Permalink
style(response): clippy cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Jul 24, 2024
1 parent 7b14add commit 1adbf3f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use {

const CSS: &str = include_str!("../default.css");

#[allow(clippy::unused_async, clippy::future_not_send, clippy::too_many_lines)]
#[allow(clippy::future_not_send, clippy::too_many_lines)]
pub async fn default(
req: actix_web::HttpRequest,
http_request: actix_web::HttpRequest,
) -> Result<HttpResponse, Error> {
if ["/proxy", "/proxy/", "/x", "/x/", "/raw", "/raw/", "/nocss", "/nocss/"]
.contains(&req.path())
.contains(&http_request.path())
{
return Ok(
HttpResponse::Ok()
Expand All @@ -26,10 +26,11 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".<

let mut configuration = configuration::Configuration::new();
let url = match url_from_path(
&format!("{}{}", req.path(), {
if !req.query_string().is_empty() || req.uri().to_string().ends_with('?')
&format!("{}{}", http_request.path(), {
if !http_request.query_string().is_empty()
|| http_request.uri().to_string().ends_with('?')
{
format!("?{}", req.query_string())
format!("?{}", http_request.query_string())
} else {
String::new()
}
Expand Down Expand Up @@ -175,7 +176,7 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".<
html_context.push_str(&format!("<title>{gemini_title}</title>"));
html_context.push_str("</head><body>");

if !req.path().starts_with("/proxy") {
if !http_request.path().starts_with("/proxy") {
if let Ok(header) = var("HEADER") {
html_context
.push_str(&format!("<big><blockquote>{header}</blockquote></big>"));
Expand Down Expand Up @@ -236,8 +237,8 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".<

if let Ok(plain_texts) = var("PLAIN_TEXT_ROUTE") {
if plain_texts.split(',').any(|r| {
path_matches_pattern(r, req.path())
|| path_matches_pattern(r, req.path().trim_end_matches('/'))
path_matches_pattern(r, http_request.path())
|| path_matches_pattern(r, http_request.path().trim_end_matches('/'))
}) {
return Ok(HttpResponse::Ok().body(
response.content().as_ref().map_or_else(String::default, String::clone),
Expand Down

0 comments on commit 1adbf3f

Please sign in to comment.