mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +01:00
fix example
This commit is contained in:
parent
9e610a8134
commit
93707884d2
@ -8,11 +8,11 @@ extern crate env_logger;
|
|||||||
extern crate futures;
|
extern crate futures;
|
||||||
|
|
||||||
use actix_redis::RedisSessionBackend;
|
use actix_redis::RedisSessionBackend;
|
||||||
use actix_web::middleware::RequestSession;
|
use actix_web::middleware::session::{self, RequestSession};
|
||||||
use actix_web::{middleware, server, App, HttpRequest, HttpResponse, Result};
|
use actix_web::{middleware, server, App, HttpRequest, HttpResponse, Result};
|
||||||
|
|
||||||
/// simple handler
|
/// simple handler
|
||||||
fn index(mut req: HttpRequest) -> Result<HttpResponse> {
|
fn index(req: HttpRequest) -> Result<HttpResponse> {
|
||||||
println!("{:?}", req);
|
println!("{:?}", req);
|
||||||
|
|
||||||
// session
|
// session
|
||||||
@ -36,14 +36,14 @@ fn main() {
|
|||||||
// enable logger
|
// enable logger
|
||||||
.middleware(middleware::Logger::default())
|
.middleware(middleware::Logger::default())
|
||||||
// cookie session middleware
|
// cookie session middleware
|
||||||
.middleware(middleware::SessionStorage::new(
|
.middleware(session::SessionStorage::new(
|
||||||
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))
|
.resource("/", |r| r.f(index))
|
||||||
}).bind("0.0.0.0:8080")
|
}).bind("0.0.0.0:8080")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.threads(1)
|
.workers(1)
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
let _ = sys.run();
|
let _ = sys.run();
|
||||||
|
Loading…
Reference in New Issue
Block a user