generated from alecodes/base-template
30 lines
663 B
Rust
30 lines
663 B
Rust
mod error;
|
|
pub mod router;
|
|
|
|
pub use error::{Error, Result, ResultTemplate};
|
|
use minijinja::{Environment, Template};
|
|
use serde::{Deserialize, Serialize};
|
|
use std::sync::Arc;
|
|
|
|
pub type Tx = axum_sqlx_tx::Tx<sqlx::Postgres>;
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct Link {
|
|
pub path: String,
|
|
pub text: String,
|
|
pub subpages: Vec<Self>,
|
|
}
|
|
|
|
pub struct AppState {
|
|
tmpl_env: Environment<'static>,
|
|
}
|
|
|
|
impl AppState {
|
|
pub fn new(tmpl_env: Environment<'static>) -> Arc<Self> {
|
|
Arc::new(AppState { tmpl_env })
|
|
}
|
|
|
|
pub fn get_template(&self, name: &str) -> Result<Template> {
|
|
Ok(self.tmpl_env.get_template(name)?)
|
|
}
|
|
}
|