Struct actix_identity::Identity [−][src]
pub struct Identity(_);
Expand description
The extractor type to obtain your identity from a request.
use actix_web::*;
use actix_identity::Identity;
#[get("/")]
async fn index(id: Identity) -> impl Responder {
// access request identity
if let Some(id) = id.identity() {
format!("Welcome! {}", id)
} else {
"Welcome Anonymous!".to_owned()
}
}
#[post("/login")]
async fn login(id: Identity) -> impl Responder {
// remember identity
id.remember("User1".to_owned());
HttpResponse::Ok()
}
#[post("/logout")]
async fn logout(id: Identity) -> impl Responder {
// remove identity
id.forget();
HttpResponse::Ok()
}
Implementations
Return the claimed identity of the user associated request or None
if no identity can be
found associated with the request.
Trait Implementations
Extractor implementation for Identity type.
use actix_identity::Identity;
#[get("/")]
async fn index(id: Identity) -> impl Responder {
// access request identity
if let Some(id) = id.identity() {
format!("Welcome! {}", id)
} else {
"Welcome Anonymous!".to_owned()
}
}
Auto Trait Implementations
impl !RefUnwindSafe for Identity
impl !UnwindSafe for Identity
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more