Done documentation
This commit is contained in:
parent
90bce828ff
commit
9af1d7b665
3 changed files with 8 additions and 0 deletions
|
@ -23,6 +23,7 @@ use crate::states::AppState;
|
|||
async fn init() -> Result<()> {
|
||||
let app_state = AppState::build()?;
|
||||
|
||||
// The path prefix of all routes.
|
||||
let path_prefix = app_state.config.path_prefix.clone();
|
||||
|
||||
let socket_address = app_state
|
||||
|
@ -37,6 +38,7 @@ async fn init() -> Result<()> {
|
|||
app_state.config.utc_offset.minutes,
|
||||
)?;
|
||||
|
||||
// The service for serving the static files.
|
||||
let static_service =
|
||||
get_service(ServeDir::new("static")).handle_error(|_| ready(StatusCode::NOT_FOUND));
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::sync::{Arc, Mutex};
|
|||
|
||||
use crate::{captcha_solutions::CaptchaSolutions, config::Config, mailer::Mailer};
|
||||
|
||||
/// The application state.
|
||||
#[derive(Clone, FromRef)]
|
||||
pub struct AppState {
|
||||
pub config: Arc<Config>,
|
||||
|
@ -12,11 +13,13 @@ pub struct AppState {
|
|||
}
|
||||
|
||||
impl AppState {
|
||||
/// Try to build the app state.
|
||||
pub fn build() -> Result<Self> {
|
||||
let config = Config::build()?;
|
||||
let mailer = Arc::new(Mailer::build(&config)?);
|
||||
|
||||
let config = Arc::new(config);
|
||||
// Mutex for write access.
|
||||
let captcha_solutions = Arc::new(Mutex::new(CaptchaSolutions::default()));
|
||||
|
||||
Ok(Self {
|
||||
|
|
|
@ -2,11 +2,13 @@ use askama::Template;
|
|||
|
||||
use crate::{config, forms::PersistantContactFormFields};
|
||||
|
||||
/// Base template.
|
||||
pub struct Base<'a> {
|
||||
pub lang: &'a str,
|
||||
pub path_prefix: &'a str,
|
||||
}
|
||||
|
||||
/// Contact form template.
|
||||
#[derive(Template)]
|
||||
#[template(path = "contact_form.askama.html")]
|
||||
pub struct ContactForm<'a> {
|
||||
|
@ -19,6 +21,7 @@ pub struct ContactForm<'a> {
|
|||
pub strings: &'a config::Strings,
|
||||
}
|
||||
|
||||
/// Sucessful contact form submission template.
|
||||
#[derive(Template)]
|
||||
#[template(path = "success.askama.html")]
|
||||
pub struct Success<'a> {
|
||||
|
|
Loading…
Reference in a new issue