Compare commits
No commits in common. 'master' and 'refactor' have entirely different histories.
@ -1,13 +0,0 @@ |
||||
# [0.3.0] |
||||
|
||||
- Update dependencies |
||||
- Added new example |
||||
- Port to rocket `0.5.0-rc.2` |
||||
|
||||
# [0.2.2] |
||||
|
||||
- Update dependencies |
||||
|
||||
# [0.2.1] |
||||
|
||||
- change from `thread_rng` to `OsRng` for better session ID entropy |
@ -1,28 +0,0 @@ |
||||
#[macro_use] |
||||
extern crate rocket; |
||||
|
||||
use std::time::Duration; |
||||
|
||||
type Session<'a> = rocket_session::Session<'a, u64>; |
||||
|
||||
#[launch] |
||||
fn rocket() -> _ { |
||||
// This session expires in 15 seconds as a demonstration of session configuration
|
||||
rocket::build() |
||||
.attach(Session::fairing().with_lifetime(Duration::from_secs(15))) |
||||
.mount("/", routes![index]) |
||||
} |
||||
|
||||
#[get("/")] |
||||
fn index(session: Session) -> String { |
||||
let count = session.tap(|n| { |
||||
// Change the stored value (it is &mut)
|
||||
*n += 1; |
||||
|
||||
// Return something to the caller.
|
||||
// This can be any type, 'tap' is generic.
|
||||
*n |
||||
}); |
||||
|
||||
format!("{} visits", count) |
||||
} |
Loading…
Reference in new issue