1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-02-17 16:43:30 +01:00

update session impl

This commit is contained in:
Nikolay Kim 2018-01-10 16:51:09 -08:00
parent ae28b1ad81
commit abb6c6ba0a

View File

@ -12,7 +12,7 @@ use redis_async::resp::RespValue;
use cookie::{CookieJar, Cookie, Key};
use http::header::{self, HeaderValue};
use actix::prelude::*;
use actix_web::{error, Error, HttpRequest, HttpResponse};
use actix_web::{error, Error, Result, HttpRequest, HttpResponse};
use actix_web::middleware::{SessionImpl, SessionBackend, Response as MiddlewareResponse};
use redis::{Command, RedisActor};
@ -51,11 +51,12 @@ impl SessionImpl for RedisSession {
self.state.clear()
}
fn write(&self, resp: HttpResponse) -> MiddlewareResponse {
fn write(&self, resp: HttpResponse) -> Result<MiddlewareResponse> {
if self.changed {
MiddlewareResponse::Future(self.inner.update(&self.state, resp, self.value.as_ref()))
Ok(MiddlewareResponse::Future(
self.inner.update(&self.state, resp, self.value.as_ref())))
} else {
MiddlewareResponse::Done(resp)
Ok(MiddlewareResponse::Done(resp))
}
}
}