sa-token-plugin-ntex 0.1.5

Ntex framework integration for sa-token-rust - All-in-one package
Documentation

sa-token-plugin-ntex

为 Ntex 框架提供 sa-token 认证和授权支持 Provides sa-token authentication and authorization support for Ntex framework

特性 | Features

  • ✨ 一行导入所有功能 | One-line import for all functionalities
  • 🔧 支持多种存储后端 | Support for multiple storage backends
  • 🚀 简化的中间件集成 | Simplified middleware integration
  • 📦 包含核心、宏、存储 | Includes core, macros, and storage

快速开始 | Quick Start

[dependencies]
sa-token-plugin-ntex = "0.1.5"
use sa_token_plugin_ntex::*;

#[ntex::main]
async fn main() -> std::io::Result<()> {
    let storage = Arc::new(MemoryStorage::new());
    
    SaTokenConfig::builder()
        .token_name("Authorization")
        .timeout(7200)
        .storage(storage)
        .build();
    
    ntex::web::HttpServer::new(|| {
        ntex::web::App::new()
            .route("/login", ntex::web::post().to(login_handler))
            .route("/user", ntex::web::get().to(user_handler))
    })
    .bind("127.0.0.1:8080")?
    .run()
    .await
}