codify "platform" into resolution logic, server-fn/fullstack overhaul (#4596)
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.
This commit is contained in:
1 parent
8421c3aef0
commit
f2b1c6d97f
424 files changed
+17284
-6624
No files matched your search
@@ -0,0 +1,37 @@
|
||||
//! This example shows how to get access to the full axum request in a handler.
|
||||
//!
|
||||
//! The extra arguments in the `post` macro are passed to the handler function, but not exposed
|
||||
//! to the client. This means we can still call the endpoint from the client, but have full access
|
||||
//! to the request on the server.
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::launch(app);
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let mut file_id = use_action(full_request);
|
||||
|
||||
rsx! {
|
||||
div { "Access to full axum request" }
|
||||
button { onclick: move |_| file_id.call(), "Upload file" }
|
||||
}
|
||||
}
|
||||
|
||||
/// Example of accessing the full axum request in a handler
|
||||
///
|
||||
/// The `request: axum_core::extract::Request` argument is placed in the handler function, but not
|
||||
/// exposed to the client.
|
||||
#[post("/api/full_request_access", request: axum_core::extract::Request)]
|
||||
async fn full_request() -> Result<()> {
|
||||
let headers = request.headers();
|
||||
|
||||
if headers.contains_key("x-api-key") {
|
||||
println!("API key found");
|
||||
} else {
|
||||
println!("No API key found");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user