actix_session/
session_ext.rs1use actix_web::{
2    dev::{ServiceRequest, ServiceResponse},
3    guard::GuardContext,
4    HttpMessage, HttpRequest,
5};
6
7use crate::Session;
8
9pub trait SessionExt {
12    fn get_session(&self) -> Session;
14}
15
16impl SessionExt for HttpRequest {
17    fn get_session(&self) -> Session {
18        Session::get_session(&mut self.extensions_mut())
19    }
20}
21
22impl SessionExt for ServiceRequest {
23    fn get_session(&self) -> Session {
24        Session::get_session(&mut self.extensions_mut())
25    }
26}
27
28impl SessionExt for ServiceResponse {
29    fn get_session(&self) -> Session {
30        self.request().get_session()
31    }
32}
33
34impl SessionExt for GuardContext<'_> {
35    fn get_session(&self) -> Session {
36        Session::get_session(&mut self.req_data_mut())
37    }
38}