Fix layers being cloned for each request (#2586)

This commit is contained in:
David Pedersen 2024-03-14 21:24:32 +01:00 committed by GitHub
parent 3569950a2e
commit 19f6f7900f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View file

@ -7,7 +7,10 @@ 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` ([#2586])
[#2586]: https://github.com/tokio-rs/axum/pull/2586
# 0.7.4 (13. January, 2024)

View file

@ -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(())))
}
}
};

View file

@ -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(())))
}
}
};