sa_token_plugin_ntex/
lib.rs

1// Author: 金书记
2//
3// 中文 | English
4// Ntex 框架集成 | Ntex Framework Integration
5//
6//! # sa-token-plugin-ntex
7//! 
8//! 为 Ntex 框架提供 sa-token 认证和授权支持
9//! Provides sa-token authentication and authorization support for Ntex framework
10//! 
11//! ## 特性 | Features
12//! 
13//! - ✨ 一行导入所有功能 | One-line import for all functionalities
14//! - 🔧 支持多种存储后端 | Support for multiple storage backends
15//! - 🚀 简化的中间件集成 | Simplified middleware integration
16//! - 📦 包含核心、宏、存储 | Includes core, macros, and storage
17//! 
18//! ## 快速开始 | Quick Start
19//! 
20//! ```toml
21//! [dependencies]
22//! sa-token-plugin-ntex = "0.1.5"
23//! ```
24//! 
25//! ```rust,ignore
26//! use sa_token_plugin_ntex::*;
27//! 
28//! #[ntex::main]
29//! async fn main() -> std::io::Result<()> {
30//!     let storage = Arc::new(MemoryStorage::new());
31//!     
32//!     SaTokenConfig::builder()
33//!         .token_name("Authorization")
34//!         .timeout(7200)
35//!         .storage(storage)
36//!         .build();
37//!     
38//!     ntex::web::HttpServer::new(|| {
39//!         ntex::web::App::new()
40//!             .route("/login", ntex::web::post().to(login_handler))
41//!             .route("/user", ntex::web::get().to(user_handler))
42//!     })
43//!     .bind("127.0.0.1:8080")?
44//!     .run()
45//!     .await
46//! }
47//! ```
48
49pub mod middleware;
50
51// 重新导出核心功能 | Re-export core functionalities
52pub use sa_token_core::*;
53pub use sa_token_adapter::*;
54pub use sa_token_macro::*;
55
56// 重新导出存储实现(通过 feature 控制)
57// Re-export storage implementations (controlled by features)
58#[cfg(feature = "memory")]
59pub use sa_token_storage_memory::*;
60
61#[cfg(feature = "redis")]
62pub use sa_token_storage_redis::*;
63
64#[cfg(feature = "database")]
65pub use sa_token_storage_database::*;
66
67// 重新导出本模块的适配器 | Re-export adapters from this module
68pub use middleware::*;
69