1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-23 23:51:06 +01:00

update readme

This commit is contained in:
Nikolay Kim 2019-12-20 22:11:38 +06:00
parent 9b0a0f451b
commit 2e1d98a4be

View File

@ -4,11 +4,10 @@ Redis integration for actix framework.
## Documentation ## Documentation
* [API Documentation (Development)](http://actix.github.io/actix-redis/actix_redis/) * [API Documentation](http://actix.github.io/actix-redis/actix_redis/)
* [API Documentation (Releases)](https://docs.rs/actix-redis/)
* [Chat on gitter](https://gitter.im/actix/actix) * [Chat on gitter](https://gitter.im/actix/actix)
* Cargo package: [actix-redis](https://crates.io/crates/actix-redis) * Cargo package: [actix-redis](https://crates.io/crates/actix-redis)
* Minimum supported Rust version: 1.26 or later * Minimum supported Rust version: 1.39 or later
## Redis session backend ## Redis session backend
@ -24,32 +23,25 @@ Note that whatever you write into your session is visible by the user (but not m
Constructor panics if key length is less than 32 bytes. Constructor panics if key length is less than 32 bytes.
```rust ```rust
extern crate actix_web; use actix_web::{App, HttpServer, web, middleware};
extern crate actix_redis;
use actix_web::{App, server, middleware};
use actix_web::middleware::session::SessionStorage; use actix_web::middleware::session::SessionStorage;
use actix_redis::RedisSessionBackend; use actix_redis::RedisSessionBackend;
fn main() { #[actix_rt::main]
::std::env::set_var("RUST_LOG", "actix_web=info"); async fn main() -> std::io::Result {
env_logger::init(); HttpServer::new(|| App::new()
let sys = actix::System::new("basic-example"); // enable logger
.middleware(middleware::Logger::default())
server::new( // cookie session middleware
|| App::new() .middleware(SessionStorage::new(
// enable logger RedisSessionBackend::new("127.0.0.1:6379", &[0; 32])
.middleware(middleware::Logger::default()) ))
// cookie session middleware // register simple route, handle all methods
.middleware(SessionStorage::new( .service(web::resource("/").to(index))
RedisSessionBackend::new("127.0.0.1:6379", &[0; 32]) )
)) .bind("0.0.0.0:8080")?
// register simple route, handle all methods .start()
.resource("/", |r| r.f(index))) .await
.bind("0.0.0.0:8080").unwrap()
.start();
let _ = sys.run();
} }
``` ```