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:
parent
b4252f8fd1
commit
8de1f60347
1 changed files with 18 additions and 0 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue