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;
fn index(id: Identity) -> Result<String> {
// access request identity
if let Some(id) = id.identity() {
Ok(format!("Welcome! {}", id))
} else {
Ok("Welcome Anonymous!".to_owned())
}
}
fn login(id: Identity) -> HttpResponse {
id.remember("User1".to_owned()); // <- remember identity
HttpResponse::Ok().finish()
}
fn logout(id: Identity) -> HttpResponse {
id.forget(); // <- remove identity
HttpResponse::Ok().finish()
}
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;
fn index(id: Identity) -> String {
// access request identity
if let Some(id) = id.identity() {
format!("Welcome! {}", id)
} else {
"Welcome Anonymous!".to_owned()
}
}
Convert request to a Self
Convert request to a Self Read more
Auto Trait Implementations
impl !RefUnwindSafe for Identity
impl !UnwindSafe for Identity
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
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