pub async fn handle(req: Request, env: Env) -> Result<Response>Expand description
Handle an incoming Cloudflare Worker request by dispatching it through the Dioxus server function router.
This is a convenience wrapper around Handler::new().handle().
Use Handler directly if you need before/after middleware hooks.
§Example
ⓘ
use worker::*;
extern "C" { fn __wasm_call_ctors(); }
#[event(fetch)]
async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> {
// Required: initialize inventory for server function registration.
// SAFETY: Called once per Worker cold start. The `inventory` crate
// requires this in WASM to register #[server] functions.
unsafe { __wasm_call_ctors(); }
dioxus_cloudflare::handle(req, env).await
}