1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 08:22:59 +01:00

add session extractor doc api

This commit is contained in:
Nikolay Kim 2018-05-16 21:05:59 -07:00
parent b4252f8fd1
commit 8de1f60347

View File

@ -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::<i32>("counter")? {
/// session.set("counter", count+1)?;
/// } else {
/// session.set("counter", 1)?;
/// }
///
/// Ok("Welcome!")
/// }
/// # fn main() {}
/// ```
impl<S> FromRequest<S> for Session { impl<S> FromRequest<S> for Session {
type Config = (); type Config = ();
type Result = Session; type Result = Session;