docs.rs failed to build dioxus-server-0.7.0-alpha.3
Please check the
build logs for more information.
See
Builds for ideas on how to fix a failed build,
or
Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault,
open an issue.
Dioxus utilities for the Axum server framework.
Example
#![allow(non_snake_case)]
use dioxus::prelude::*;
fn main() {
#[cfg(feature = "web")]
dioxus::launch(app);
#[cfg(feature = "server")]
{
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
let address = dioxus::cli_config::fullstack_address_or_localhost();
let listener = tokio::net::TcpListener::bind(address)
.await
.unwrap();
axum::serve(
listener,
axum::Router::new()
.serve_dioxus_application(ServeConfigBuilder::default(), app)
.into_make_service(),
)
.await
.unwrap();
});
}
}
fn app() -> Element {
let mut text = use_signal(|| "Click the button to run a server function".to_string());
rsx! {
button {
onclick: move |_| async move {
if let Ok(data) = get_server_data().await {
text.set(data);
}
},
"Run a server function"
}
"Server said: {text}"
}
}
#[server(GetServerData)]
async fn get_server_data() -> ServerFnResult<String> {
Ok("Hello from the server!".to_string())
}