* improve documentation for the fullstack server context * Add a section about axum integration to the crate root docs * make serve_dioxus_application accept the cfg builder directly * remove unused server_fn module * improve fullstack config docs * improve documentation for the server function macro * fix axum router extension link * Fix doc tests * Fix launch builder * Simplify the launch builder * don't re-export launch in the prelude * refactor fullstack launch * Fix fullstack launch builder * Update static generation with the new builder api * fix some formatting/overly broad launch replacements * fix custom menu example * fix fullstack/static generation examples * Fix static generation launch * A few small formatting fixes * Fix a few doc tests * implement LaunchConfig for serve configs * fix fullstack launch with separate web and server launch methods * fix check with all features * dont expose inner core module * clippy and check * fix readme --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
38 lines
1.3 KiB
Rust
38 lines
1.3 KiB
Rust
//! 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();
|
|
});
|
|
}
|