axum_session_manager/
lib.rs

1//! Session manage system for axum.  
2//! ## OverView
3//! Sessions are managed using cookies, and session-related operations 
4//! (issuing a session ID, checking sessions, deleting sessions) can be implemented with SessionManageTrait, 
5//! and session checking is automatically performed at all endpoints by `axum::routing::Router::layer` and [`tower::Service`] as middleware.  
6//! At each endpoint, whether a user has a session can be received as UserData via axum::extension::Extention, 
7//! and data about the user who has a session is also included there.
8//! ## feature
9//! The important parts of this crate are the [`SessionManage`] trait, the [`UserData`] struct, and the [`UserState`] enum.  
10//! ## usage
11//! ### implment session manage system as amiddleware
12//! 1. define session pool
13//! 2. implement [`SessionManage`] trait for session pool you defined step 1
14//! 3. Create [`SessionManagerLayer`] struct by using [`SessionManagerLayer::new()`] method
15//! 4. insert [`SessionManagerLayer`] struct you defined step 3, into axum::route::layer 
16//! ### get data in your handler
17//! 1. use `Extention<UserData<T>>`
18//! 2. get data in [`UserData`] struct tuple field
19//! 3.  matching [`UserState`] HaveSession, NoCookie, NoSession case  
20//! 
21//! Please see example for more details.
22
23pub use layer::SessionManagerLayer;
24pub use manager::{SessionManage, UserData, UserState};
25
26pub mod layer;
27pub mod manager;
28mod service;