An adapter to easily allow an Axum server to be run within a Cloudflare worker.
```rust use worker::*;
use axum::{ response::{Html}, routing::get, Router as AxumRouter, }; use axumcloudflareadapter::{toaxumrequest, toworkerresponse}; use tower_service::Service;
async fn index() -> Html<&'static str> { Html("
Hello from Axum!
") }pub async fn main(req: Request, _env: Env, _ctx: worker::Context) -> Result
let axum_request = to_axum_request(req).await.unwrap();
let axum_response = _router.call(axum_request).await.unwrap();
let response = to_worker_response(axum_response).await.unwrap();
Ok(response)
} ```
wasm-pack test --firefox --headless
cargo build --target wasm32-unknown-unknown
The /example
directory contains a Cloudflare worker running an Axum sever