diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index 8da7cb802..4ee939cee 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -25,6 +25,10 @@ redis-session-native-tls = ["redis-session", "redis/tokio-native-tls-comp"] redis-session-rustls = ["redis-session", "redis/tokio-rustls-comp"] redis-pool = ["dep:deadpool-redis"] +context = [] +juniper = ["context"] + + [dependencies] actix-service = "2" actix-utils = "3" @@ -41,6 +45,10 @@ tracing = { version = "0.1.30", default-features = false, features = ["log"] } redis = { version = "0.27", default-features = false, features = ["tokio-comp", "connection-manager"], optional = true } deadpool-redis = { version = "0.18", optional = true } +# Context +juniper = { version = "0.16.1", default-features = false } + + [dev-dependencies] actix-session = { path = ".", features = ["cookie-session", "redis-session"] } actix-test = "0.1" diff --git a/actix-session/src/context.rs b/actix-session/src/context.rs new file mode 100644 index 000000000..c85cfeaf6 --- /dev/null +++ b/actix-session/src/context.rs @@ -0,0 +1,3 @@ +/// Support juniper::executor::Context `https://docs.rs/juniper/0.16.1/juniper/executor/trait.Context.html` +#[cfg(feature = "juniper")] +impl juniper::Context for crate::Session {} diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index 1ad600bab..56be9b59b 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -136,11 +136,13 @@ #![cfg_attr(docsrs, feature(doc_auto_cfg))] pub mod config; +#[cfg(feature = "context")] +/// Using the Session as a context for other crates +pub mod context; mod middleware; mod session; mod session_ext; pub mod storage; - pub use self::{ middleware::SessionMiddleware, session::{Session, SessionGetError, SessionInsertError, SessionStatus},