refactor: clean up unused code and improve conditionals in various modules

This commit is contained in:
GW_MC
2026-07-18 04:59:42 +00:00
parent 83037f3ee2
commit 076e87695d
11 changed files with 35 additions and 81 deletions

View File

@@ -1,7 +1,6 @@
use std::sync::Arc;
use sea_orm::DatabaseConnection;
use tonic::transport::Server;
pub mod ssh;

View File

@@ -33,10 +33,10 @@ pub async fn update_agent_handler(
Path(id): Path<uuid::Uuid>,
Json(body): Json<UpdateAgentRequest>,
) -> Result<impl IntoResponse, AppError> {
if let Some(ref name) = body.name {
if name.trim().is_empty() {
return Err(AppError::BadRequest("name must not be empty".to_string()));
}
if let Some(ref name) = body.name
&& name.trim().is_empty()
{
return Err(AppError::BadRequest("name must not be empty".to_string()));
}
let rec = UpdateAgentRecord {

View File

@@ -93,7 +93,7 @@ async fn get_config(
Path(id): Path<Uuid>,
) -> Result<Json<serde_json::Value>, AppError> {
let config = svc.get_proxy_config(id).await?;
Ok(Json(serde_json::to_value(&config.id).unwrap_or_default()))
Ok(Json(serde_json::to_value(config.id).unwrap_or_default()))
}
async fn update_config(

View File

@@ -131,7 +131,7 @@ impl CertificateService for CertificateServiceImpl {
.collect::<Vec<SanType>>(),
san_dns
.into_iter()
.map(|dns| SanType::DnsName(dns))
.map(SanType::DnsName)
.collect::<Vec<SanType>>(),
]
.concat();

View File

@@ -16,10 +16,10 @@ impl std::fmt::Display for ProxySettingRender<'_> {
if let Some(buffer) = self.setting.buffer_size {
writeln!(f, " proxy_buffer_size {};", buffer)?;
}
if self.setting.cache_enabled.unwrap_or(false) {
if let Some(zone_name) = self.cache_zone_name {
writeln!(f, " proxy_cache {};", zone_name)?;
}
if self.setting.cache_enabled.unwrap_or(false)
&& let Some(zone_name) = self.cache_zone_name
{
writeln!(f, " proxy_cache {};", zone_name)?;
}
Ok(())
}

View File

@@ -18,10 +18,10 @@ impl std::fmt::Display for ServerBlockRender<'_> {
writeln!(f, " listen {};", self.block.listen_port)?;
}
if let Some(ref names) = self.block.server_name {
if !names.is_empty() {
writeln!(f, " server_name {};", names.join(" "))?;
}
if let Some(ref names) = self.block.server_name
&& !names.is_empty()
{
writeln!(f, " server_name {};", names.join(" "))?;
}
if let Some(cert) = self.ssl_cert {