Skip to content

Commit

Permalink
Removed redundent log invokes and adopted clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eshanatnight committed Jan 12, 2024
1 parent c3c0f42 commit 4677a85
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions server/src/handlers/livetail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,43 +193,30 @@ pub fn server() -> impl Future<Output = Result<(), Box<dyn std::error::Error + S
};

let config = match identity {
Some(id) => {
log::info!("TLS enabled");
ServerTlsConfig::new().identity(id)
}
None => {
log::info!("TLS disabled");
ServerTlsConfig::new()
}
Some(id) => ServerTlsConfig::new().identity(id),
None => ServerTlsConfig::new(),
};

// rust is treating closures for map_err ad different types? so I have to do this
let err_map_fn = |err| Box::new(err) as Box<dyn std::error::Error + Send>;

let server = Server::builder();
match server.tls_config(config) {
Ok(server) => {
return server
.accept_http1(true)
.layer(cors)
.layer(GrpcWebLayer::new())
.add_service(svc)
.serve(addr)
.map_err(err_map_fn);
}

Err(err) => {
log::warn!("TLS disabled due to missing certificate or key");
log::warn!("Error: {:?}", err);
log::warn!("Proceeding without TLS");
return Server::builder()
.accept_http1(true)
.layer(cors)
.layer(GrpcWebLayer::new())
.add_service(svc)
.serve(addr)
.map_err(err_map_fn);
}
Ok(server) => server
.accept_http1(true)
.layer(cors)
.layer(GrpcWebLayer::new())
.add_service(svc)
.serve(addr)
.map_err(err_map_fn),

Err(_) => Server::builder()
.accept_http1(true)
.layer(cors)
.layer(GrpcWebLayer::new())
.add_service(svc)
.serve(addr)
.map_err(err_map_fn),
}
}

Expand Down

0 comments on commit 4677a85

Please sign in to comment.