inertia_rust/
temporary_session.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use serde::Serialize;
use serde_json::{Map, Value};

/// `InertiaTemporarySession` struct contains data that InertiaMiddleware will try to extract
/// from the request and merge with shared props.
///
/// You must inject it by yourself by a second middleware, which gets these information from
/// your framework sessions manager.
#[derive(Clone, Serialize, Debug)]
pub struct InertiaTemporarySession {
    pub errors: Option<Map<String, Value>>,
    pub prev_req_url: String,
}

impl Default for InertiaTemporarySession {
    fn default() -> Self {
        InertiaTemporarySession {
            errors: None,
            prev_req_url: "/".to_string(),
        }
    }
}

pub struct InertiaSessionToReflash(pub InertiaTemporarySession);