Skip to content

Commit

Permalink
Set default status code to 200 after goal exexuted (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn authored Sep 24, 2024
1 parent 494fb5c commit 2c4e8c3
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions crates/core/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 2c4e8c3

Please sign in to comment.