mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
update doc strings
This commit is contained in:
parent
64d867d9a1
commit
626999bcc9
@ -20,6 +20,23 @@ use httpresponse::HttpResponse;
|
||||
use middlewares::{Middleware, Started, Response};
|
||||
|
||||
/// The helper trait to obtain your session data from a request.
|
||||
///
|
||||
/// ```rust
|
||||
/// use actix_web::*;
|
||||
/// use actix_web::middlewares::RequestSession;
|
||||
///
|
||||
/// fn index(mut req: HttpRequest) -> Result<&'static str> {
|
||||
/// // access session data
|
||||
/// if let Some(count) = req.session().get::<i32>("counter")? {
|
||||
/// req.session().set("counter", count+1)?;
|
||||
/// } else {
|
||||
/// req.session().set("counter", 1)?;
|
||||
/// }
|
||||
///
|
||||
/// Ok("Welcome!")
|
||||
/// }
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
pub trait RequestSession {
|
||||
fn session(&mut self) -> Session;
|
||||
}
|
||||
@ -101,12 +118,13 @@ unsafe impl Sync for SessionImplBox {}
|
||||
/// ```rust
|
||||
/// # extern crate actix;
|
||||
/// # extern crate actix_web;
|
||||
/// # use actix_web::middlewares::{SessionStorage, CookieSessionBackend};
|
||||
/// use actix_web::*;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let app = Application::new()
|
||||
/// .middleware(middlewares::SessionStorage::new( // <- create session middlewares
|
||||
/// middlewares::CookieSessionBackend::build(&[0; 32]) // <- create cookie session backend
|
||||
/// let app = Application::new().middleware(
|
||||
/// SessionStorage::new( // <- create session middlewares
|
||||
/// CookieSessionBackend::build(&[0; 32]) // <- create cookie session backend
|
||||
/// .secure(false)
|
||||
/// .finish())
|
||||
/// );
|
||||
|
Loading…
Reference in New Issue
Block a user