mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 23:51:06 +01:00
tweak docs
This commit is contained in:
parent
673b77a765
commit
12f6db3755
@ -7,7 +7,7 @@
|
|||||||
//!
|
//!
|
||||||
//! To access current request identity, use the [`Identity`] extractor.
|
//! To access current request identity, use the [`Identity`] extractor.
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```
|
||||||
//! use actix_web::*;
|
//! use actix_web::*;
|
||||||
//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
|
//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
|
||||||
//!
|
//!
|
||||||
@ -23,20 +23,20 @@
|
|||||||
//!
|
//!
|
||||||
//! #[post("/login")]
|
//! #[post("/login")]
|
||||||
//! async fn login(id: Identity) -> HttpResponse {
|
//! async fn login(id: Identity) -> HttpResponse {
|
||||||
//! id.remember("User1".to_owned()); // <- remember identity
|
//! // remember identity
|
||||||
|
//! id.remember("User1".to_owned());
|
||||||
//! HttpResponse::Ok().finish()
|
//! HttpResponse::Ok().finish()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! #[post("/logout")]
|
//! #[post("/logout")]
|
||||||
//! async fn logout(id: Identity) -> HttpResponse {
|
//! async fn logout(id: Identity) -> HttpResponse {
|
||||||
//! id.forget(); // <- remove identity
|
//! // remove identity
|
||||||
|
//! id.forget();
|
||||||
//! HttpResponse::Ok().finish()
|
//! HttpResponse::Ok().finish()
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! #[actix_web::main]
|
|
||||||
//! async fn main() -> std::io::Result<()> {
|
|
||||||
//! HttpServer::new(move || {
|
//! HttpServer::new(move || {
|
||||||
//! // create cookie identity backend
|
//! // create cookie identity backend (inside closure, since policy is not Clone)
|
||||||
//! let policy = CookieIdentityPolicy::new(&[0; 32])
|
//! let policy = CookieIdentityPolicy::new(&[0; 32])
|
||||||
//! .name("auth-cookie")
|
//! .name("auth-cookie")
|
||||||
//! .secure(false);
|
//! .secure(false);
|
||||||
@ -46,10 +46,7 @@
|
|||||||
//! .wrap(IdentityService::new(policy))
|
//! .wrap(IdentityService::new(policy))
|
||||||
//! .service(services![index, login, logout])
|
//! .service(services![index, login, logout])
|
||||||
//! })
|
//! })
|
||||||
//! .bind(("0.0.0.0", 8080u16))?
|
//! # ;
|
||||||
//! .run()
|
|
||||||
//! .await
|
|
||||||
//! }
|
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![deny(rust_2018_idioms, nonstandard_style)]
|
#![deny(rust_2018_idioms, nonstandard_style)]
|
||||||
|
Loading…
Reference in New Issue
Block a user