dioxus_static_site_generation/
launch.rs

1//! This module contains the `launch` function, which is the main entry point for dioxus fullstack
2
3use std::any::Any;
4
5use dioxus_lib::prelude::Element;
6
7/// Launch a fullstack app with the given root component, contexts, and config.
8#[allow(unused)]
9pub fn launch(
10    root: fn() -> Element,
11    contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
12    platform_config: Vec<Box<dyn Any>>,
13) {
14    #[cfg(feature = "server")]
15    tokio::runtime::Runtime::new()
16        .unwrap()
17        .block_on(async move {
18            use axum::extract::Path;
19            use axum::response::IntoResponse;
20            use axum::routing::get;
21            use axum::Router;
22            use axum::ServiceExt;
23            use http::StatusCode;
24            use tower_http::services::ServeDir;
25            use tower_http::services::ServeFile;
26            let platform_config = platform_config
27                .into_iter()
28                .find_map(|cfg| cfg.downcast::<crate::Config>().map(|cfg| *cfg).ok())
29                .unwrap_or_else(crate::Config::new);
30
31            let github_pages = platform_config.github_pages;
32            let path = platform_config.output_dir.clone();
33            crate::ssg::generate_static_site(root, platform_config)
34                .await
35                .unwrap();
36        });
37}