Skip to content

Commit

Permalink
Fix layers being cloned for each request
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn committed Feb 11, 2024
1 parent 62324aa commit eb17e84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion axum/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

# Unreleased

- None.
- **fixed:** Fixed layers being cloned when calling `axum::serve` directly with
a `Router` or `MethodRouter`

# 0.7.4 (13. January, 2024)

Expand Down
2 changes: 1 addition & 1 deletion axum/src/routing/method_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ const _: () = {
}

fn call(&mut self, _req: IncomingStream<'_>) -> Self::Future {
std::future::ready(Ok(self.clone()))
std::future::ready(Ok(self.clone().with_state(())))
}
}
};
Expand Down
4 changes: 3 additions & 1 deletion axum/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ const _: () = {
}

fn call(&mut self, _req: IncomingStream<'_>) -> Self::Future {
std::future::ready(Ok(self.clone()))
// call `Router::with_state` such that everything is turned into `Route` eagerly
// rather than doing that per request
std::future::ready(Ok(self.clone().with_state(())))
}
}
};
Expand Down

0 comments on commit eb17e84

Please sign in to comment.