1 个不稳定版本
0.0.1 | 2021年7月26日 |
---|
#14 在 #marco
在 actix-loginmanager 中使用
6KB
60 代码行
actix-loginmanager的登录必需宏
语法
#[login_required(UserType,name="user")]
属性
UserType
- 定义变量类型。name="user"
- 定义变量名称。
示例
use actix_loginmanager::login_required;
// define or import `user` which implements `UserMinix` trait.
#[login_required(User)]
async fn hello()->impl actix_web::Responder{
user.is_actived(); //can access user:Rc<User>
return "hello";
}
#[login_required(User,name="user")]
async fn hello()->impl actix_web::Responder{
user.is_actived(); //can access user:Rc<User>
return "hello";
}
lib.rs
:
actix-loginmanager的登录必需宏
示例
use actix_loginmanager::login_required;
// define or import `user` which implements `UserMinix` trait.
#[login_required(User)]
async fn hello()->impl actix_web::Responder{
user.is_actived(); //can access user:Rc<User>
return "hello";
}
#[login_required(User, name="user")]
async fn hello()->impl actix_web::Responder{
user.is_actived(); //can access user:Rc<User>
return "hello";
}
依赖
~1.5MB
~35K SLoC