dioxus_static_site_generation/
launch.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! This module contains the `launch` function, which is the main entry point for dioxus fullstack

use std::any::Any;

use dioxus_lib::prelude::Element;

/// Launch a fullstack app with the given root component, contexts, and config.
#[allow(unused)]
pub fn launch(
    root: fn() -> Element,
    contexts: Vec<Box<dyn Fn() -> Box<dyn Any> + Send + Sync>>,
    platform_config: Vec<Box<dyn Any>>,
) {
    #[cfg(feature = "server")]
    tokio::runtime::Runtime::new()
        .unwrap()
        .block_on(async move {
            use axum::extract::Path;
            use axum::response::IntoResponse;
            use axum::routing::get;
            use axum::Router;
            use axum::ServiceExt;
            use http::StatusCode;
            use tower_http::services::ServeDir;
            use tower_http::services::ServeFile;
            let platform_config = platform_config
                .into_iter()
                .find_map(|cfg| cfg.downcast::<crate::Config>().map(|cfg| *cfg).ok())
                .unwrap_or_else(crate::Config::new);

            let github_pages = platform_config.github_pages;
            let path = platform_config.output_dir.clone();
            crate::ssg::generate_static_site(root, platform_config)
                .await
                .unwrap();
        });
}