diff --git a/axum-extra/CHANGELOG.md b/axum-extra/CHANGELOG.md index 9eb2affa..0ca46010 100644 --- a/axum-extra/CHANGELOG.md +++ b/axum-extra/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning]. except that it enforces field exclusivity at runtime instead of compile time, as this improves usability. +- **added:** Implement `Clone` for `CookieJar`, `PrivateCookieJar` and `SignedCookieJar` ([#1808]) + +[#1808]: https://github.com/tokio-rs/axum/pull/1808 + # 0.6.0 (24. February, 2022) - **breaking:** Change casing of `ProtoBuf` to `Protobuf` ([#1595]) diff --git a/axum-extra/src/extract/cookie/mod.rs b/axum-extra/src/extract/cookie/mod.rs index ca05c836..175bf9e6 100644 --- a/axum-extra/src/extract/cookie/mod.rs +++ b/axum-extra/src/extract/cookie/mod.rs @@ -83,7 +83,7 @@ pub use cookie::Key; /// .route("/me", get(me)); /// # let app: Router = app; /// ``` -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct CookieJar { jar: cookie::CookieJar, } diff --git a/axum-extra/src/extract/cookie/private.rs b/axum-extra/src/extract/cookie/private.rs index bd7f17fa..c1b55dbd 100644 --- a/axum-extra/src/extract/cookie/private.rs +++ b/axum-extra/src/extract/cookie/private.rs @@ -301,3 +301,13 @@ impl<'a, K> Iterator for PrivateCookieJarIter<'a, K> { } } } + +impl Clone for PrivateCookieJar { + fn clone(&self) -> Self { + Self { + jar: self.jar.clone(), + key: self.key.clone(), + _marker: self._marker, + } + } +} diff --git a/axum-extra/src/extract/cookie/signed.rs b/axum-extra/src/extract/cookie/signed.rs index 5f26b9c5..911082f1 100644 --- a/axum-extra/src/extract/cookie/signed.rs +++ b/axum-extra/src/extract/cookie/signed.rs @@ -319,3 +319,13 @@ impl<'a, K> Iterator for SignedCookieJarIter<'a, K> { } } } + +impl Clone for SignedCookieJar { + fn clone(&self) -> Self { + Self { + jar: self.jar.clone(), + key: self.key.clone(), + _marker: self._marker, + } + } +}