From fbbb4a86e91b207354383b2627b0d55465bbcb79 Mon Sep 17 00:00:00 2001 From: tglman Date: Fri, 20 Dec 2019 07:59:07 +0000 Subject: [PATCH] feat: add access to the session also from immutable references (#1225) --- actix-session/CHANGES.md | 5 +++++ actix-session/src/lib.rs | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/actix-session/CHANGES.md b/actix-session/CHANGES.md index 0c9dca564..b4ef66c35 100644 --- a/actix-session/CHANGES.md +++ b/actix-session/CHANGES.md @@ -1,5 +1,10 @@ # Changes + +## [0.3.0-alpha.4] - 2019-12-xx + +* Allow access to sessions also from not mutable references to the request + ## [0.3.0-alpha.3] - 2019-12-xx * Add access to the session from RequestHead for use of session from guard methods diff --git a/actix-session/src/lib.rs b/actix-session/src/lib.rs index ef44e5213..ac60901c3 100644 --- a/actix-session/src/lib.rs +++ b/actix-session/src/lib.rs @@ -85,23 +85,23 @@ pub struct Session(Rc>); /// Helper trait that allows to get session pub trait UserSession { - fn get_session(&mut self) -> Session; + fn get_session(&self) -> Session; } impl UserSession for HttpRequest { - fn get_session(&mut self) -> Session { + fn get_session(&self) -> Session { Session::get_session(&mut *self.extensions_mut()) } } impl UserSession for ServiceRequest { - fn get_session(&mut self) -> Session { + fn get_session(&self) -> Session { Session::get_session(&mut *self.extensions_mut()) } } impl UserSession for RequestHead { - fn get_session(&mut self) -> Session { + fn get_session(&self) -> Session { Session::get_session(&mut *self.extensions_mut()) } }