Crates.io | actix-sled-session |
lib.rs | actix-sled-session |
version | 0.2.0 |
source | src |
created_at | 2019-09-17 23:39:36.02897 |
updated_at | 2019-10-16 16:33:35.127244 |
description | An Actix Web Session Backend using the Sled embedded database |
homepage | |
repository | https://git.asonix.dog/Aardwolf/actix-sled-session |
max_upload_size | |
id | 165565 |
size | 141,183 |
An Actix Web Session Backend using the Sled embedded database
This session backend sets an cookie with a unique ID for each incoming request that doesn't already have an ID set, and uses that ID as a key to look up session data from a Sled tree.
[dependencies]
actix = "0.8"
actix-sled-session = "0.2"
actix-web = "1.0"
use actix::System;
use actix_web::{web, App, HttpServer};
use actix_sled_session::{Session, SledSession};
fn index(session: Session) -> String {
if let Ok(Some(item)) = session.get::<usize>("item") {
println!("item, {}", item);
session.clear();
return format!("Got item, {}", item);
}
let _ = session.set::<usize>("item", 3);
String::from("Set item!")
}
fn main() -> Result<(), failure::Error> {
let sys = System::new("example");
let session_backend = SledSession::new_default()?;
HttpServer::new(move || {
App::new()
.wrap(session_backend.clone())
.route("/", web::get().to(index))
})
.bind("127.0.0.1:9876")?
.start();
sys.run()?;
Ok(())
}
Unless otherwise stated, all contributions to this project will be licensed under the CSL with the exceptions listed in the License section of this file.
This work is licensed under the Cooperative Software License. This is not a Free Software License, but may be considered a "source-available License." For most hobbyists, self-employed developers, worker-owned companies, and cooperatives, this software can be used in most projects so long as this software is distributed under the terms of the CSL. For more information, see the provided LICENSE file. If none exists, the license can be found online here. If you are a free software project and wish to use this software under the terms of the GNU Affero General Public License, please contact me at asonix@asonix.dog and we can sort that out. If you wish to use this project under any other license, especially in proprietary software, the answer is likely no.