Skip to content

Commit

Permalink
axum-core v0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcountryman committed Jan 1, 2025
1 parent 3b94a4c commit c005ac5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ tower-service = "0.3.2"
tower-sessions-core = { workspace = true }
tower-sessions-memory-store = { workspace = true, optional = true }
tracing = { version = "0.1.40", features = ["log"] }
tower-cookies = "0.10.0"
tower-cookies = "0.11.0"
time = { version = "0.3.29", features = ["serde"] }

[dev-dependencies]
async-trait = "0.1.74"
anyhow = "1"
axum = "0.7.1"
axum-core = "0.4.0"
axum = "0.8.1"
axum-core = "0.5.0"
futures = { version = "0.3.28", default-features = false, features = [
"async-await",
] }
Expand All @@ -84,7 +84,7 @@ time = "0.3.30"
tokio = { version = "1.32.0", features = ["full"] }
tokio-test = "0.4.3"
tower = { version = "0.5.0", features = ["util"] }
tower-cookies = "0.10.0"
tower-cookies = "0.11.0"
tower-sessions-core = { workspace = true, features = ["deletion-task"] }

[[example]]
Expand Down
2 changes: 0 additions & 2 deletions examples/counter-extractor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::net::SocketAddr;

use async_trait::async_trait;
use axum::{extract::FromRequestParts, response::IntoResponse, routing::get, Router};
use http::request::Parts;
use serde::{Deserialize, Serialize};
Expand All @@ -12,7 +11,6 @@ const COUNTER_KEY: &str = "counter";
#[derive(Default, Deserialize, Serialize)]
struct Counter(usize);

#[async_trait]
impl<S> FromRequestParts<S> for Counter
where
S: Send + Sync,
Expand Down
2 changes: 0 additions & 2 deletions examples/strongly-typed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{fmt, net::SocketAddr};

use async_trait::async_trait;
use axum::{extract::FromRequestParts, response::IntoResponse, routing::get, Router};
use http::{request::Parts, StatusCode};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -67,7 +66,6 @@ impl fmt::Display for Guest {
}
}

#[async_trait]
impl<S> FromRequestParts<S> for Guest
where
S: Send + Sync,
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
//! #[derive(Default, Deserialize, Serialize)]
//! struct Counter(usize);
//!
//! #[async_trait]
//! impl<S> FromRequestParts<S> for Counter
//! where
//! S: Send + Sync,
Expand Down Expand Up @@ -221,7 +220,6 @@
//! }
//! }
//!
//! #[async_trait]
//! impl<S> FromRequestParts<S> for Guest
//! where
//! S: Send + Sync,
Expand Down
11 changes: 5 additions & 6 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'a> SessionConfig<'a> {
}
}

impl<'a> Default for SessionConfig<'a> {
impl Default for SessionConfig<'_> {
fn default() -> Self {
Self {
name: "id".into(), /* See: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-id-name-fingerprinting */
Expand Down Expand Up @@ -547,9 +547,8 @@ mod tests {
use tower::{ServiceBuilder, ServiceExt};
use tower_sessions_memory_store::MemoryStore;

use crate::session::{Id, Record};

use super::*;
use crate::session::{Id, Record};

async fn handler(req: Request<Body>) -> anyhow::Result<Response<Body>> {
let session = req
Expand Down Expand Up @@ -791,7 +790,7 @@ mod tests {
let sid1 = get_session_id(&res1);
let rec1 = get_record(&session_store, &sid1).await;
let req2 = Request::builder()
.header(http::header::COOKIE, &format!("id={}", sid1))
.header(http::header::COOKIE, format!("id={}", sid1))
.body(Body::empty())?;
let res2 = svc.call(req2).await?;
let sid2 = get_session_id(&res2);
Expand Down Expand Up @@ -820,7 +819,7 @@ mod tests {
let sid1 = get_session_id(&res1);
let rec1 = get_record(&session_store, &sid1).await;
let req2 = Request::builder()
.header(http::header::COOKIE, &format!("id={}", sid1))
.header(http::header::COOKIE, format!("id={}", sid1))
.body(Body::empty())?;
let res2 = svc.call(req2).await?;
let sid2 = get_session_id(&res2);
Expand Down Expand Up @@ -850,7 +849,7 @@ mod tests {
let sid1 = get_session_id(&res1);
let rec1 = get_record(&session_store, &sid1).await;
let req2 = Request::builder()
.header(http::header::COOKIE, &format!("id={}", sid1))
.header(http::header::COOKIE, format!("id={}", sid1))
.body(Body::empty())?;
let res2 = svc.call(req2).await?;
let sid2 = get_session_id(&res2);
Expand Down
2 changes: 1 addition & 1 deletion tower-sessions-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ deletion-task = ["tokio/time"]

[dependencies]
async-trait = { workspace = true }
axum-core = { version = "0.4", optional = true }
axum-core = { version = "0.5.0", optional = true }
base64 = "0.22.0"
futures = { version = "0.3.28", default-features = false, features = [
"async-await",
Expand Down
2 changes: 0 additions & 2 deletions tower-sessions-core/src/extract.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use async_trait::async_trait;
use axum_core::extract::FromRequestParts;
use http::{request::Parts, StatusCode};

use crate::session::Session;

#[async_trait]
impl<S> FromRequestParts<S> for Session
where
S: Sync + Send,
Expand Down

0 comments on commit c005ac5

Please sign in to comment.