rustream/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/// Landing page template that is served as HTML response while streaming media.
6mod landing;
7/// Listing page template that is served as HTML response after successful authentication.
8mod listing;
9/// Logout page template that is served as HTML response when the user decides to end the session.
10mod logout;
11/// Session page template that is served as HTML response when invalid/expired session tokens are received.
12mod session;
13/// Error page template that is served as HTML response for any error message to be conveyed.
14mod error;
15mod upload;
16mod profile;
17
18/// Loads all the HTML templates' content into a Jinja Environment
19///
20/// # Returns
21///
22/// Returns the constructed `Arc` for the `Environment` object, that holds the central configuration state for templates.
23/// It is also the container for all loaded templates.
24pub fn environment() -> Arc<minijinja::Environment<'static>> {
25    let mut env = minijinja::Environment::new();
26    env.add_template_owned("index", index::get_content()).unwrap();
27    env.add_template_owned("landing", landing::get_content()).unwrap();
28    env.add_template_owned("listing", listing::get_content()).unwrap();
29    env.add_template_owned("logout", logout::get_content()).unwrap();
30    env.add_template_owned("session", session::get_content()).unwrap();
31    env.add_template_owned("error", error::get_content()).unwrap();
32    env.add_template_owned("upload", upload::get_content()).unwrap();
33    env.add_template_owned("profile", profile::get_content()).unwrap();
34    Arc::new(env)
35}