mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-23 23:51:06 +01:00
feat: add access to the session also from immutable references (#1225)
This commit is contained in:
parent
1d12ba9d5f
commit
fbbb4a86e9
@ -1,5 +1,10 @@
|
|||||||
# Changes
|
# 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
|
## [0.3.0-alpha.3] - 2019-12-xx
|
||||||
|
|
||||||
* Add access to the session from RequestHead for use of session from guard methods
|
* Add access to the session from RequestHead for use of session from guard methods
|
||||||
|
@ -85,23 +85,23 @@ pub struct Session(Rc<RefCell<SessionInner>>);
|
|||||||
|
|
||||||
/// Helper trait that allows to get session
|
/// Helper trait that allows to get session
|
||||||
pub trait UserSession {
|
pub trait UserSession {
|
||||||
fn get_session(&mut self) -> Session;
|
fn get_session(&self) -> Session;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserSession for HttpRequest {
|
impl UserSession for HttpRequest {
|
||||||
fn get_session(&mut self) -> Session {
|
fn get_session(&self) -> Session {
|
||||||
Session::get_session(&mut *self.extensions_mut())
|
Session::get_session(&mut *self.extensions_mut())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserSession for ServiceRequest {
|
impl UserSession for ServiceRequest {
|
||||||
fn get_session(&mut self) -> Session {
|
fn get_session(&self) -> Session {
|
||||||
Session::get_session(&mut *self.extensions_mut())
|
Session::get_session(&mut *self.extensions_mut())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserSession for RequestHead {
|
impl UserSession for RequestHead {
|
||||||
fn get_session(&mut self) -> Session {
|
fn get_session(&self) -> Session {
|
||||||
Session::get_session(&mut *self.extensions_mut())
|
Session::get_session(&mut *self.extensions_mut())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user