mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-27 00:00:24 +02:00
Use new Cargo features to avoid implicit features for optional dependencies (#1239)
* Fix changelog entry for MSRV change in axum-extra 0.3.5 * Bump MSRV to 1.60 for axum, axum-extra, axum-macros * Use new Cargo features to avoid implicit features for optional dependencies
This commit is contained in:
@@ -23,10 +23,10 @@ pub use self::private::PrivateCookieJar;
|
||||
#[cfg(feature = "cookie-signed")]
|
||||
pub use self::signed::SignedCookieJar;
|
||||
|
||||
pub use cookie_lib::{Cookie, Expiration, SameSite};
|
||||
pub use cookie::{Cookie, Expiration, SameSite};
|
||||
|
||||
#[cfg(any(feature = "cookie-signed", feature = "cookie-private"))]
|
||||
pub use cookie_lib::Key;
|
||||
pub use cookie::Key;
|
||||
|
||||
/// Extractor that grabs cookies from the request and manages the jar.
|
||||
///
|
||||
@@ -84,7 +84,7 @@ pub use cookie_lib::Key;
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct CookieJar {
|
||||
jar: cookie_lib::CookieJar,
|
||||
jar: cookie::CookieJar,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@@ -95,7 +95,7 @@ where
|
||||
type Rejection = Infallible;
|
||||
|
||||
async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
|
||||
let mut jar = cookie_lib::CookieJar::new();
|
||||
let mut jar = cookie::CookieJar::new();
|
||||
for cookie in cookies_from_request(req) {
|
||||
jar.add_original(cookie);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ impl IntoResponse for CookieJar {
|
||||
}
|
||||
}
|
||||
|
||||
fn set_cookies(jar: cookie_lib::CookieJar, headers: &mut HeaderMap) {
|
||||
fn set_cookies(jar: cookie::CookieJar, headers: &mut HeaderMap) {
|
||||
for cookie in jar.delta() {
|
||||
if let Ok(header_value) = cookie.encoded().to_string().parse() {
|
||||
headers.append(SET_COOKIE, header_value);
|
||||
|
||||
@@ -5,7 +5,7 @@ use axum::{
|
||||
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
|
||||
Extension,
|
||||
};
|
||||
use cookie_lib::PrivateJar;
|
||||
use cookie::PrivateJar;
|
||||
use std::{convert::Infallible, fmt, marker::PhantomData};
|
||||
|
||||
/// Extractor that grabs private cookies from the request and manages the jar.
|
||||
@@ -57,7 +57,7 @@ use std::{convert::Infallible, fmt, marker::PhantomData};
|
||||
/// # let app: Router<axum::body::Body> = app;
|
||||
/// ```
|
||||
pub struct PrivateCookieJar<K = Key> {
|
||||
jar: cookie_lib::CookieJar,
|
||||
jar: cookie::CookieJar,
|
||||
key: Key,
|
||||
// The key used to extract the key extension. Allows users to use multiple keys for different
|
||||
// jars. Maybe a library wants its own key.
|
||||
@@ -84,7 +84,7 @@ where
|
||||
async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
|
||||
let key = Extension::<K>::from_request(req).await?.0.into();
|
||||
|
||||
let mut jar = cookie_lib::CookieJar::new();
|
||||
let mut jar = cookie::CookieJar::new();
|
||||
let mut private_jar = jar.private_mut(&key);
|
||||
for cookie in cookies_from_request(req) {
|
||||
if let Some(cookie) = private_jar.decrypt(cookie) {
|
||||
@@ -176,11 +176,11 @@ impl<K> PrivateCookieJar<K> {
|
||||
}
|
||||
}
|
||||
|
||||
fn private_jar(&self) -> PrivateJar<&'_ cookie_lib::CookieJar> {
|
||||
fn private_jar(&self) -> PrivateJar<&'_ cookie::CookieJar> {
|
||||
self.jar.private(&self.key)
|
||||
}
|
||||
|
||||
fn private_jar_mut(&mut self) -> PrivateJar<&'_ mut cookie_lib::CookieJar> {
|
||||
fn private_jar_mut(&mut self) -> PrivateJar<&'_ mut cookie::CookieJar> {
|
||||
self.jar.private_mut(&self.key)
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ impl<K> IntoResponse for PrivateCookieJar<K> {
|
||||
|
||||
struct PrivateCookieJarIter<'a, K> {
|
||||
jar: &'a PrivateCookieJar<K>,
|
||||
iter: cookie_lib::Iter<'a>,
|
||||
iter: cookie::Iter<'a>,
|
||||
}
|
||||
|
||||
impl<'a, K> Iterator for PrivateCookieJarIter<'a, K> {
|
||||
|
||||
@@ -5,8 +5,8 @@ use axum::{
|
||||
response::{IntoResponse, IntoResponseParts, Response, ResponseParts},
|
||||
Extension,
|
||||
};
|
||||
use cookie_lib::SignedJar;
|
||||
use cookie_lib::{Cookie, Key};
|
||||
use cookie::SignedJar;
|
||||
use cookie::{Cookie, Key};
|
||||
use std::{convert::Infallible, fmt, marker::PhantomData};
|
||||
|
||||
/// Extractor that grabs signed cookies from the request and manages the jar.
|
||||
@@ -75,7 +75,7 @@ use std::{convert::Infallible, fmt, marker::PhantomData};
|
||||
/// # let app: Router<axum::body::Body> = app;
|
||||
/// ```
|
||||
pub struct SignedCookieJar<K = Key> {
|
||||
jar: cookie_lib::CookieJar,
|
||||
jar: cookie::CookieJar,
|
||||
key: Key,
|
||||
// The key used to extract the key extension. Allows users to use multiple keys for different
|
||||
// jars. Maybe a library wants its own key.
|
||||
@@ -102,7 +102,7 @@ where
|
||||
async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
|
||||
let key = Extension::<K>::from_request(req).await?.0.into();
|
||||
|
||||
let mut jar = cookie_lib::CookieJar::new();
|
||||
let mut jar = cookie::CookieJar::new();
|
||||
let mut signed_jar = jar.signed_mut(&key);
|
||||
for cookie in cookies_from_request(req) {
|
||||
if let Some(cookie) = signed_jar.verify(cookie) {
|
||||
@@ -195,11 +195,11 @@ impl<K> SignedCookieJar<K> {
|
||||
}
|
||||
}
|
||||
|
||||
fn signed_jar(&self) -> SignedJar<&'_ cookie_lib::CookieJar> {
|
||||
fn signed_jar(&self) -> SignedJar<&'_ cookie::CookieJar> {
|
||||
self.jar.signed(&self.key)
|
||||
}
|
||||
|
||||
fn signed_jar_mut(&mut self) -> SignedJar<&'_ mut cookie_lib::CookieJar> {
|
||||
fn signed_jar_mut(&mut self) -> SignedJar<&'_ mut cookie::CookieJar> {
|
||||
self.jar.signed_mut(&self.key)
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ impl<K> IntoResponse for SignedCookieJar<K> {
|
||||
|
||||
struct SignedCookieJarIter<'a, K> {
|
||||
jar: &'a SignedCookieJar<K>,
|
||||
iter: cookie_lib::Iter<'a>,
|
||||
iter: cookie::Iter<'a>,
|
||||
}
|
||||
|
||||
impl<'a, K> Iterator for SignedCookieJarIter<'a, K> {
|
||||
|
||||
Reference in New Issue
Block a user