From 2c4e8c3a40636b8c60a352461bf62752f5c61db1 Mon Sep 17 00:00:00 2001 From: Chrislearn Young Date: Tue, 24 Sep 2024 12:52:03 +0800 Subject: [PATCH] Set default status code to 200 after goal exexuted (#926) --- crates/core/src/service.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/core/src/service.rs b/crates/core/src/service.rs index e2e27106a..d7ee9135b 100644 --- a/crates/core/src/service.rs +++ b/crates/core/src/service.rs @@ -227,19 +227,15 @@ impl HyperHandler { req.params = path_state.params; // Set default status code before service hoops executed. // We hope all hoops in service can get the correct status code. - let mut ctrl = if !hoops.is_empty() { - FlowCtrl::new( - [ - &hoops[..], - &[Arc::new(DefaultStatusOK)], - &dm.hoops[..], - &[dm.goal], - ] - .concat(), - ) - } else { - FlowCtrl::new([&dm.hoops[..], &[dm.goal]].concat()) - }; + let mut ctrl = FlowCtrl::new( + [ + &hoops[..], + &dm.hoops[..], + &[Arc::new(DefaultStatusOK)], + &[dm.goal], + ] + .concat(), + ); ctrl.call_next(&mut req, &mut depot, &mut res).await; // Set it to default status code again if any hoop set status code to None. if res.status_code.is_none() {