1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-02-17 08:33:30 +01:00

docs(identity): clarify policy creation (#198)

This commit is contained in:
nerix 2022-03-01 05:21:18 +01:00 committed by GitHub
parent ce92f0036f
commit 673b77a765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,7 @@
//!
//! To access current request identity, use the [`Identity`] extractor.
//!
//! ```
//! ```no_run
//! use actix_web::*;
//! use actix_identity::{Identity, CookieIdentityPolicy, IdentityService};
//!
@ -33,15 +33,23 @@
//! HttpResponse::Ok().finish()
//! }
//!
//! // create cookie identity backend
//! let policy = CookieIdentityPolicy::new(&[0; 32])
//! .name("auth-cookie")
//! .secure(false);
//! #[actix_web::main]
//! async fn main() -> std::io::Result<()> {
//! HttpServer::new(move || {
//! // create cookie identity backend
//! let policy = CookieIdentityPolicy::new(&[0; 32])
//! .name("auth-cookie")
//! .secure(false);
//!
//! let app = App::new()
//! // wrap policy into middleware identity middleware
//! .wrap(IdentityService::new(policy))
//! .service(services![index, login, logout]);
//! App::new()
//! // wrap policy into middleware identity middleware
//! .wrap(IdentityService::new(policy))
//! .service(services![index, login, logout])
//! })
//! .bind(("0.0.0.0", 8080u16))?
//! .run()
//! .await
//! }
//! ```
#![deny(rust_2018_idioms, nonstandard_style)]