fn from_request(&self, req: &HttpRequest<S>) -> Self::Future {
        let inner = Rc::clone(&self.0);
        let conn_ip = req.connection_info()
            .remote()
            .map_or("0.0.0.0", |s| s.split(":").nth(0).unwrap())
            .to_owned();

        let unk = HeaderValue::from_static("Unknown");
        let ua = req.headers()
            .get("user-agent")
            .unwrap_or(&unk)
            .to_str()
            .unwrap_or("Unknown")
            .to_owned();

        Box::new(self.0.load(req).map(move |ident| {
            if let Some(id) = ident {

                SqlIdentity {
                    id: id.id,
                    identity: Some(id.userid),
                    token: Some(id.token),
                    ip: Some(conn_ip),
                    user_agent: Some(ua),
                    created: id.created,
                    state: SqlIdentityState::Updated,
                    inner: inner,
                }
            } else {
                SqlIdentity {
                    id: -1,
                    identity: None,
                    token: None,
                    ip: Some(conn_ip),
                    user_agent: Some(ua),
                    created: Utc::now().naive_utc(),
                    state: SqlIdentityState::Unchanged,
                    inner: inner,
                }
            }
        }))
    }
/// Process a request recieved by the server, returns an Identity struct
///
/// # Arguments
///
/// * `req` - The HTTP request recieved
Process a request recieved by the server, returns an Identity struct
Process a request recieved by the server returns an Identity struct
fn from_request(&self, req: &HttpRequest<S>) -> Self::Future {
        let inner = Rc::clone(&self.0);
        let conn_ip = req.connection_info()
            .remote()
            .map_or("0.0.0.0", |s| s.split(":").nth(0).unwrap())
            .to_owned();
        let unk = HeaderValue::from_static("Unknown");
        let ua = req.headers()
            .get("user-agent")
            .unwrap_or(&unk)
            .to_str()
            .unwrap_or("Unknown")
            .to_owned();
        Box::new(self.0.load(req).map(move |ident| {
            if let Some(id) = ident {
                SqlIdentity {
                    id: id.id,
                    identity: Some(id.userid),
                    token: Some(id.token),
                    ip: Some(conn_ip),
                    user_agent: Some(ua),
                    created: id.created,
                    state: SqlIdentityState::Updated,
                    inner: inner,
                }
            } else {
                SqlIdentity {
                    id: -1,
                    identity: None,
                    token: None,
                    ip: Some(conn_ip),
                    user_agent: Some(ua),
                    created: Utc::now().naive_utc(),
                    state: SqlIdentityState::Unchanged,
                    inner: inner,
                }
            }
        }))
    }
fn from_request ( & self , req : & HttpRequest < S > ) -> Self :: Future { let inner = Rc :: clone ( & self . 0 ) ; let conn_ip = req . connection_info ( ) . remote ( ) . map_or ( " " , | s | s . split ( " " ) . nth ( 0 ) . unwrap ( ) ) . to_owned ( ) ; let unk = HeaderValue :: from_static ( " " ) ; let ua = req . headers ( ) . get ( " " ) . unwrap_or ( & unk ) . to_str ( ) . unwrap_or ( " " ) . to_owned ( ) ; Box :: new ( self . 0 . load ( req ) . map ( move | ident | { if let Some ( id ) = ident { SqlIdentity { id : id . id , identity : Some ( id . userid ) , token : Some ( id . token ) , ip : Some ( conn_ip ) , user_agent : Some ( ua ) , created : id . created , state : SqlIdentityState :: Updated , inner : inner , } } else { SqlIdentity { id : - 1 , identity : None , token : None , ip : Some ( conn_ip ) , user_agent : Some ( ua ) , created : Utc :: now ( ) . naive_utc ( ) , state : SqlIdentityState :: Unchanged , inner : inner , } } } ) ) }
Process a request recieved by the server, returns an Identity struct
Process a request recieved by the server returns an Identity struct
&self
req
&HttpRequest<S>
&self
req
&HttpRequest<S>