From 8de1f60347638bb29080a16042758ac883a6bad4 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 16 May 2018 21:05:59 -0700 Subject: [PATCH] add session extractor doc api --- src/middleware/session.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/middleware/session.rs b/src/middleware/session.rs index 4565cc119..6225bc34f 100644 --- a/src/middleware/session.rs +++ b/src/middleware/session.rs @@ -191,6 +191,24 @@ impl Session { } } +/// Extractor implementation for Session type. +/// +/// ```rust +/// # use actix_web::*; +/// use actix_web::middleware::session::Session; +/// +/// fn index(session: Session) -> Result<&'static str> { +/// // access session data +/// if let Some(count) = session.get::("counter")? { +/// session.set("counter", count+1)?; +/// } else { +/// session.set("counter", 1)?; +/// } +/// +/// Ok("Welcome!") +/// } +/// # fn main() {} +/// ``` impl FromRequest for Session { type Config = (); type Result = Session;