//! # Rust Letter Backend //! //! `rust_letter_be` handles the backend execution using Rocket. #[macro_use] extern crate rocket; /// A module that handles the backend for the site. pub mod web_app_backend { use rocket::fs::FileServer; use rocket::{Rocket, Build}; use rocket_dyn_templates::{Template, context}; use void_fe::void_app::{self, VirtualDom}; #[get("/")] async fn index() -> Template { let mut vdom = VirtualDom::new(void_app::HomePage); let _ = vdom.rebuild(); let output = dioxus_ssr::render(&vdom); Template::render( "index", context! { app_title: "A Letter to the Void", style_include: "", test: &output }, ) } /// This runs `rocket::build()` with the needed mounts and routes. pub async fn build_rocket() -> Rocket { rocket::build() .mount("/images", FileServer::from("public/images")) .mount("/styles", FileServer::from("public/styles")) .mount("/fonts", FileServer::from("public/fonts")) .mount("/", routes![index]).attach(Template::fairing()) } }