mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
add session extractor doc api
This commit is contained in:
parent
b4252f8fd1
commit
8de1f60347
@ -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 New Issue
Block a user