Skip to content

Commit

Permalink
fix(core): fix HoopedHandler::handle FlowCtrl (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
andeya authored Nov 7, 2024
1 parent d4fa9e8 commit 555addb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions crates/core/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,19 @@ impl Handler for HoopedHandler {
req: &mut Request,
depot: &mut Depot,
res: &mut Response,
_ctrl: &mut FlowCtrl,
ctrl: &mut FlowCtrl,
) {
let inner: Arc<dyn Handler> = self.inner.clone();
let mut ctrl = FlowCtrl::new(self.hoops.iter().chain([&inner]).cloned().collect());
let right = ctrl.handlers.split_off(ctrl.cursor);
ctrl.handlers.append(
&mut self
.hoops
.iter()
.cloned()
.chain([inner])
.chain(right)
.collect(),
);
ctrl.call_next(req, depot, res).await;
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ fn decode_url_path_safely(path: &str) -> String {
pub struct FlowCtrl {
catching: Option<bool>,
is_ceased: bool,
cursor: usize,
pub(crate) cursor: usize,
pub(crate) handlers: Vec<Arc<dyn Handler>>,
}

Expand Down

0 comments on commit 555addb

Please sign in to comment.