forked from Deuxfleurs/tricot
Cargo clippy
This commit is contained in:
parent
8d1162f206
commit
9bd922adf9
3 changed files with 10 additions and 10 deletions
|
@ -213,7 +213,7 @@ async fn select_target_and_proxy(
|
||||||
let host = if let Some(auth) = req.uri().authority() {
|
let host = if let Some(auth) = req.uri().authority() {
|
||||||
auth.as_str()
|
auth.as_str()
|
||||||
} else {
|
} else {
|
||||||
match req.headers().get("host").map(|x| x.to_str().ok()).flatten() {
|
match req.headers().get("host").and_then(|x| x.to_str().ok()) {
|
||||||
Some(host) => host,
|
Some(host) => host,
|
||||||
None => {
|
None => {
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
|
@ -268,7 +268,7 @@ async fn select_target_and_proxy(
|
||||||
debug!("{}{} -> {}", host, path, proxy_to);
|
debug!("{}{} -> {}", host, path, proxy_to);
|
||||||
trace!("Request: {:?}", req);
|
trace!("Request: {:?}", req);
|
||||||
|
|
||||||
let response = match do_proxy(&https_config, remote_addr, req, proxy_to).await {
|
let response = match do_proxy(https_config, remote_addr, req, proxy_to).await {
|
||||||
Ok(resp) => resp,
|
Ok(resp) => resp,
|
||||||
Err(e) => Response::builder()
|
Err(e) => Response::builder()
|
||||||
.status(StatusCode::BAD_GATEWAY)
|
.status(StatusCode::BAD_GATEWAY)
|
||||||
|
@ -279,7 +279,7 @@ async fn select_target_and_proxy(
|
||||||
proxy_to.calls_in_progress.fetch_sub(1, Ordering::SeqCst);
|
proxy_to.calls_in_progress.fetch_sub(1, Ordering::SeqCst);
|
||||||
metrics
|
metrics
|
||||||
.request_proxy_duration
|
.request_proxy_duration
|
||||||
.record(received_time.elapsed().as_secs_f64(), &tags);
|
.record(received_time.elapsed().as_secs_f64(), tags);
|
||||||
|
|
||||||
trace!("Final response: {:?}", response);
|
trace!("Final response: {:?}", response);
|
||||||
info!("{} {} {}", method, response.status().as_u16(), uri);
|
info!("{} {} {}", method, response.status().as_u16(), uri);
|
||||||
|
@ -323,7 +323,7 @@ async fn do_proxy(
|
||||||
}
|
}
|
||||||
|
|
||||||
if https_config.enable_compression {
|
if https_config.enable_compression {
|
||||||
response = try_compress(response, method, accept_encoding, &https_config).await?
|
response = try_compress(response, method, accept_encoding, https_config).await?
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -192,10 +192,10 @@ async fn main() {
|
||||||
|
|
||||||
let dump_task = tokio::spawn(dump_config_on_change(rx_proxy_config, exit_signal.clone()));
|
let dump_task = tokio::spawn(dump_config_on_change(rx_proxy_config, exit_signal.clone()));
|
||||||
|
|
||||||
let _ = metrics_task.await.expect("Tokio task await failure");
|
metrics_task.await.expect("Tokio task await failure");
|
||||||
let _ = http_task.await.expect("Tokio task await failure");
|
http_task.await.expect("Tokio task await failure");
|
||||||
let _ = https_task.await.expect("Tokio task await failure");
|
https_task.await.expect("Tokio task await failure");
|
||||||
let _ = dump_task.await.expect("Tokio task await failure");
|
dump_task.await.expect("Tokio task await failure");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn dump_config_on_change(
|
async fn dump_config_on_change(
|
||||||
|
@ -205,7 +205,7 @@ async fn dump_config_on_change(
|
||||||
while !*must_exit.borrow() {
|
while !*must_exit.borrow() {
|
||||||
select!(
|
select!(
|
||||||
c = rx_proxy_config.changed() => {
|
c = rx_proxy_config.changed() => {
|
||||||
if !c.is_ok() {
|
if c.is_err() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ async fn create_proxied_response<B: std::default::Default + Send + Sync + 'stati
|
||||||
*new_res.headers_mut().unwrap() = new_headers;
|
*new_res.headers_mut().unwrap() = new_headers;
|
||||||
Ok(new_res.body(B::default())?)
|
Ok(new_res.body(B::default())?)
|
||||||
} else {
|
} else {
|
||||||
return Err(anyhow!("Switching protocols but not an upgrade request"));
|
Err(anyhow!("Switching protocols but not an upgrade request"))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*response.headers_mut() = new_headers;
|
*response.headers_mut() = new_headers;
|
||||||
|
|
Loading…
Reference in a new issue