overhaul dioxus fullstack using a new implementation of server_fn This PR is a complete rewrite of dioxus fullstack designed to improve compatibility with axum and to fix a number of compilation errors based on feature flag unification plumbing through macros.
25 lines
782 B
Rust
25 lines
782 B
Rust
//! A simple example using Dioxus Fullstack to call a server action.
|
|
//!
|
|
//! the `get`, `post`, `put`, `delete`, etc macros are used to define server actions that can be
|
|
//! called from the client. The action can take arguments and return a value, and the client
|
|
//! will automatically serialize and deserialize the data.
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
fn main() {
|
|
dioxus::launch(|| {
|
|
let mut message = use_action(get_message);
|
|
|
|
rsx! {
|
|
h1 { "Server says: "}
|
|
pre { "{message:?}"}
|
|
button { onclick: move |_| message.call("world".into(), 30), "Click me!" }
|
|
}
|
|
});
|
|
}
|
|
|
|
#[get("/api/{name}/?age")]
|
|
async fn get_message(name: String, age: i32) -> Result<String> {
|
|
Ok(format!("Hello {}, you are {} years old!", name, age))
|
|
}
|