1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-23 15:51:06 +01:00
This commit is contained in:
Rob Ede 2022-09-25 21:08:34 +01:00
parent d28ab6eaa1
commit da0a806e8d
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
4 changed files with 7 additions and 7 deletions

View File

@ -135,7 +135,7 @@ async fn increment(session: Session, user: Option<Identity>) -> HttpResponse {
.get::<i32>("counter") .get::<i32>("counter")
.unwrap_or(Some(0)) .unwrap_or(Some(0))
.map_or(1, |inner| inner + 1); .map_or(1, |inner| inner + 1);
session.insert("counter", &counter).unwrap(); session.insert("counter", counter).unwrap();
HttpResponse::Ok().json(&EndpointResponse { HttpResponse::Ok().json(&EndpointResponse {
user_id, user_id,

View File

@ -674,7 +674,7 @@ pub mod test_helpers {
.get::<i32>("counter") .get::<i32>("counter")
.unwrap_or(Some(0)) .unwrap_or(Some(0))
.map_or(1, |inner| inner + 1); .map_or(1, |inner| inner + 1);
session.insert("counter", &counter)?; session.insert("counter", counter)?;
Ok(HttpResponse::Ok().json(&IndexResponse { user_id, counter })) Ok(HttpResponse::Ok().json(&IndexResponse { user_id, counter }))
} }

View File

@ -222,7 +222,7 @@ impl Session {
req: &mut ServiceRequest, req: &mut ServiceRequest,
data: impl IntoIterator<Item = (String, String)>, data: impl IntoIterator<Item = (String, String)>,
) { ) {
let session = Session::get_session(&mut *req.extensions_mut()); let session = Session::get_session(&mut req.extensions_mut());
let mut inner = session.0.borrow_mut(); let mut inner = session.0.borrow_mut();
inner.state.extend(data); inner.state.extend(data);
} }
@ -285,7 +285,7 @@ impl FromRequest for Session {
#[inline] #[inline]
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future { fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future {
ready(Ok(Session::get_session(&mut *req.extensions_mut()))) ready(Ok(Session::get_session(&mut req.extensions_mut())))
} }
} }

View File

@ -15,13 +15,13 @@ pub trait SessionExt {
impl SessionExt for HttpRequest { impl SessionExt for HttpRequest {
fn get_session(&self) -> Session { fn get_session(&self) -> Session {
Session::get_session(&mut *self.extensions_mut()) Session::get_session(&mut self.extensions_mut())
} }
} }
impl SessionExt for ServiceRequest { impl SessionExt for ServiceRequest {
fn get_session(&self) -> Session { fn get_session(&self) -> Session {
Session::get_session(&mut *self.extensions_mut()) Session::get_session(&mut self.extensions_mut())
} }
} }
@ -33,6 +33,6 @@ impl SessionExt for ServiceResponse {
impl<'a> SessionExt for GuardContext<'a> { impl<'a> SessionExt for GuardContext<'a> {
fn get_session(&self) -> Session { fn get_session(&self) -> Session {
Session::get_session(&mut *self.req_data_mut()) Session::get_session(&mut self.req_data_mut())
} }
} }