@@ -95,24 +95,37 @@ pub async fn start_health_server(port: u16, health_state: HealthState) {
9595 let health_state_status = health_state;
9696
9797 // /healthz - Kubernetes liveness probe
98- // Returns 200 if the process is alive
98+ // Returns 200 if the process is alive.
99+ //
100+ // Body type is `String` (not `&str`) because `Reply` is only implemented
101+ // for `&'static str`; using owned `String` avoids inferring a non-'static
102+ // closure return type. The `.boxed()` on the final filter chain is the
103+ // companion fix — without it, the warp 0.4 filter type carries a higher-
104+ // ranked `AsRef<str>` bound that propagates through `tokio::spawn` and
105+ // fails `Send + 'static`.
99106 let healthz = warp:: path ( "healthz" ) . map ( move || {
100107 if health_state_healthz. is_healthy ( ) {
101- warp:: reply:: with_status ( "OK" , warp:: http:: StatusCode :: OK )
108+ warp:: reply:: with_status ( "OK" . to_string ( ) , warp:: http:: StatusCode :: OK )
102109 } else {
103110 error ! ( "Health check failed" ) ;
104- warp:: reply:: with_status ( "UNHEALTHY" , warp:: http:: StatusCode :: SERVICE_UNAVAILABLE )
111+ warp:: reply:: with_status (
112+ "UNHEALTHY" . to_string ( ) ,
113+ warp:: http:: StatusCode :: SERVICE_UNAVAILABLE ,
114+ )
105115 }
106116 } ) ;
107117
108118 // /readyz - Kubernetes readiness probe
109- // Returns 200 if the controller is ready to serve traffic
119+ // Returns 200 if the controller is ready to serve traffic.
110120 let readyz = warp:: path ( "readyz" ) . map ( move || {
111121 if health_state_readyz. is_ready ( ) {
112- warp:: reply:: with_status ( "OK" , warp:: http:: StatusCode :: OK )
122+ warp:: reply:: with_status ( "OK" . to_string ( ) , warp:: http:: StatusCode :: OK )
113123 } else {
114124 debug ! ( "Readiness check failed - controller not ready" ) ;
115- warp:: reply:: with_status ( "NOT READY" , warp:: http:: StatusCode :: SERVICE_UNAVAILABLE )
125+ warp:: reply:: with_status (
126+ "NOT READY" . to_string ( ) ,
127+ warp:: http:: StatusCode :: SERVICE_UNAVAILABLE ,
128+ )
116129 }
117130 } ) ;
118131
@@ -122,17 +135,18 @@ pub async fn start_health_server(port: u16, health_state: HealthState) {
122135 warp:: reply:: json ( & status)
123136 } ) ;
124137
125- // Legacy endpoints for backward compatibility
126- let health_legacy =
127- warp :: path ( "health" ) . map ( || warp:: reply:: with_status ( "OK" , warp:: http:: StatusCode :: OK ) ) ;
128- let ready_legacy =
129- warp :: path ( "ready" ) . map ( || warp:: reply:: with_status ( "OK" , warp:: http:: StatusCode :: OK ) ) ;
138+ // Legacy endpoints for backward compatibility.
139+ let health_legacy = warp :: path ( "health" )
140+ . map ( || warp:: reply:: with_status ( "OK" . to_string ( ) , warp:: http:: StatusCode :: OK ) ) ;
141+ let ready_legacy = warp :: path ( "ready" )
142+ . map ( || warp:: reply:: with_status ( "OK" . to_string ( ) , warp:: http:: StatusCode :: OK ) ) ;
130143
131144 let routes = healthz
132145 . or ( readyz)
133146 . or ( status)
134147 . or ( health_legacy)
135- . or ( ready_legacy) ;
148+ . or ( ready_legacy)
149+ . boxed ( ) ;
136150
137151 warp:: serve ( routes) . run ( ( [ 0 , 0 , 0 , 0 ] , port) ) . await ;
138152}
0 commit comments