mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
update readme
This commit is contained in:
parent
9b0a0f451b
commit
2e1d98a4be
30
README.md
30
README.md
@ -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,20 +23,13 @@ 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");
|
|
||||||
|
|
||||||
server::new(
|
|
||||||
|| App::new()
|
|
||||||
// enable logger
|
// enable logger
|
||||||
.middleware(middleware::Logger::default())
|
.middleware(middleware::Logger::default())
|
||||||
// cookie session middleware
|
// cookie session middleware
|
||||||
@ -45,11 +37,11 @@ fn main() {
|
|||||||
RedisSessionBackend::new("127.0.0.1:6379", &[0; 32])
|
RedisSessionBackend::new("127.0.0.1:6379", &[0; 32])
|
||||||
))
|
))
|
||||||
// register simple route, handle all methods
|
// register simple route, handle all methods
|
||||||
.resource("/", |r| r.f(index)))
|
.service(web::resource("/").to(index))
|
||||||
.bind("0.0.0.0:8080").unwrap()
|
)
|
||||||
.start();
|
.bind("0.0.0.0:8080")?
|
||||||
|
.start()
|
||||||
let _ = sys.run();
|
.await
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user