Skip to content

Commit

Permalink
improved start_proxy in http
Browse files Browse the repository at this point in the history
  • Loading branch information
doroved committed Oct 25, 2024
1 parent 5c62b41 commit b214671
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,13 @@ pub async fn start_proxy(
};

let make_service = make_service_fn(move |addr: &AddrStream| {
let proxy_clone = proxy.clone();
let time = formatted_time();
println!(
"\n\x1b[1m[{time}] [HTTP server] New connection from: {}\x1b[0m",
addr.remote_addr()
);

let proxy_clone = proxy.clone();

async move { Ok::<_, hyper::Error>(service_fn(move |req| proxy_clone.clone().proxy(req))) }
});

Expand All @@ -189,5 +188,5 @@ pub async fn start_proxy(
.http1_title_case_headers(true)
.serve(make_service)
.await
.map_err(|err| err.into())
.map_err(Into::into)
}

0 comments on commit b214671

Please sign in to comment.