diff --git a/src/main.rs b/src/main.rs index 013e7af..21ed82a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ mod states; mod templates; use anyhow::Result; -use axum::routing::{get, post}; +use axum::routing::get; use axum::{Router, Server}; use axum_extra::routing::SpaRouter; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; @@ -42,9 +42,7 @@ async fn init() -> Result<()> { }; let routes = Router::new() - .route("/", get(routes::index)) - .route("/", post(routes::submit)) - .route("/success", get(routes::success)) + .route("/", get(routes::index).post(routes::submit)) .with_state(app_state); let spa = SpaRouter::new(&format!("{}/static", &path_prefix), "static"); diff --git a/src/routes.rs b/src/routes.rs index 7236628..20ba812 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -117,13 +117,12 @@ pub async fn submit( } } - info!("Successful contact form submission"); - success(State(config)).await + success(config).await } -pub async fn success( - State(config): State>, -) -> Result { +pub async fn success(config: Arc) -> Result { + info!("Successful contact form submission"); + let template = templates::Success { path_prefix: &config.path_prefix, message: &config.strings.success,