1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-23 16:40:37 +00: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;