Skip to content

Commit 4dd3e37

Browse files
committed
refactor: [#281] split TrackerServicesView::render into helper methods
Extract focused helper methods for each service type: - render_udp_trackers - render_http_trackers (handles HTTPS, direct, and localhost-only) - render_api_endpoint - render_health_check This improves readability by separating rendering logic for each tracker service category into its own method.
1 parent 17903f0 commit 4dd3e37

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

src/presentation/views/commands/show/environment_info/tracker_services.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,26 @@ impl TrackerServicesView {
2828
"Tracker Services:".to_string(),
2929
];
3030

31-
// UDP Trackers
32-
if !services.udp_trackers.is_empty() {
33-
lines.push(" UDP Trackers:".to_string());
34-
for url in &services.udp_trackers {
35-
lines.push(format!(" - {url}"));
36-
}
31+
Self::render_udp_trackers(services, &mut lines);
32+
Self::render_http_trackers(services, &mut lines);
33+
Self::render_api_endpoint(services, &mut lines);
34+
Self::render_health_check(services, &mut lines);
35+
36+
lines
37+
}
38+
39+
fn render_udp_trackers(services: &ServiceInfo, lines: &mut Vec<String>) {
40+
if services.udp_trackers.is_empty() {
41+
return;
3742
}
3843

44+
lines.push(" UDP Trackers:".to_string());
45+
for url in &services.udp_trackers {
46+
lines.push(format!(" - {url}"));
47+
}
48+
}
49+
50+
fn render_http_trackers(services: &ServiceInfo, lines: &mut Vec<String>) {
3951
// HTTPS-enabled HTTP trackers (via Caddy)
4052
if !services.https_http_trackers.is_empty() {
4153
lines.push(" HTTP Trackers (HTTPS via Caddy):".to_string());
@@ -62,8 +74,9 @@ impl TrackerServicesView {
6274
));
6375
}
6476
}
77+
}
6578

66-
// API endpoint with HTTPS indicator and localhost-only marker
79+
fn render_api_endpoint(services: &ServiceInfo, lines: &mut Vec<String>) {
6780
if services.api_is_localhost_only {
6881
lines.push(" API Endpoint (internal only):".to_string());
6982
lines.push(format!(
@@ -77,8 +90,9 @@ impl TrackerServicesView {
7790
lines.push(" API Endpoint:".to_string());
7891
lines.push(format!(" - {}", services.api_endpoint));
7992
}
93+
}
8094

81-
// Health check with HTTPS indicator and localhost-only marker
95+
fn render_health_check(services: &ServiceInfo, lines: &mut Vec<String>) {
8296
if services.health_check_is_localhost_only {
8397
lines.push(" Health Check (internal only):".to_string());
8498
lines.push(format!(
@@ -92,8 +106,6 @@ impl TrackerServicesView {
92106
lines.push(" Health Check:".to_string());
93107
lines.push(format!(" - {}", services.health_check_url));
94108
}
95-
96-
lines
97109
}
98110
}
99111

0 commit comments

Comments
 (0)