sysmonk/templates/mod.rs
1use std::sync::Arc;
2
3/// Index page template that is served as HTML response for the root endpoint.
4mod index;
5/// Logout page template that is served as HTML response when the user decides to end the session.
6mod logout;
7/// Session page template that is served as HTML response when invalid/expired session tokens are received.
8mod session;
9/// Monitor page template that is served as HTML response for the monitor endpoint.
10mod monitor;
11/// Unauthorized template that is served as HTML response when the user is unauthorized.
12mod unauthorized;
13/// Error page template that is served as HTML response for any error message to be conveyed.
14mod error;
15
16/// Loads all the HTML templates' content into a Jinja Environment
17///
18/// # Returns
19///
20/// Returns the constructed `Arc` for the `Environment` object, that holds the central configuration state for templates.
21/// It is also the container for all loaded templates.
22pub fn environment() -> Arc<minijinja::Environment<'static>> {
23 let mut env = minijinja::Environment::new();
24 env.add_template_owned("index", index::get_content()).unwrap();
25 env.add_template_owned("monitor", monitor::get_content()).unwrap();
26 env.add_template_owned("logout", logout::get_content()).unwrap();
27 env.add_template_owned("error", error::get_content()).unwrap();
28 env.add_template_owned("session", session::get_content()).unwrap();
29 env.add_template_owned("unauthorized", unauthorized::get_content()).unwrap();
30 Arc::new(env)
31}