├── .cargo └── config.toml ├── .github ├── dependabot.yml └── workflows │ ├── build-worker.yml │ └── test.yml ├── .gitignore ├── .nvmrc ├── Cargo.toml ├── README.md ├── adapter ├── Cargo.toml ├── LICENSE.md ├── README.md ├── rust-toolchain.toml └── src │ ├── error.rs │ └── lib.rs ├── example ├── .editorconfig ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md ├── package.json ├── rust-toolchain.toml ├── src │ ├── lib.rs │ └── utils.rs └── wrangler.toml └── macros ├── Cargo.toml ├── readme.md └── src └── lib.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-unknown-unknown" 3 | 4 | [target.wasm32-unknown-unknown] 5 | runner = 'wasm-bindgen-test-runner' 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "cargo" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | open-pull-requests-limit: 10 13 | 14 | - package-ecosystem: "cargo" 15 | directory: "/adapter" 16 | schedule: 17 | interval: "daily" 18 | open-pull-requests-limit: 10 19 | 20 | - package-ecosystem: "cargo" 21 | directory: "/macros" 22 | schedule: 23 | interval: "daily" 24 | open-pull-requests-limit: 10 25 | 26 | - package-ecosystem: "cargo" 27 | directory: "/example" 28 | schedule: 29 | interval: "daily" 30 | open-pull-requests-limit: 10 -------------------------------------------------------------------------------- /.github/workflows/build-worker.yml: -------------------------------------------------------------------------------- 1 | name: Verify Cloudflare worker builds 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | 13 | - name: Set up Node.js environment 14 | uses: actions/setup-node@v2 15 | with: 16 | node-version-file: '.nvmrc' 17 | 18 | - name: Install Wrangler 19 | run: npm install -g wrangler@3.78.7 20 | 21 | - name: Install Rust 22 | uses: actions-rs/toolchain@v1 23 | with: 24 | toolchain: 1.81.0 25 | target: wasm32-unknown-unknown 26 | override: true 27 | 28 | - name: Run Wrangler build 29 | run: | 30 | cd example && 31 | npx wrangler publish --dry-run --outdir=dist 32 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Run tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | 13 | - name: Install Rust 14 | uses: actions-rs/toolchain@v1 15 | with: 16 | toolchain: 1.81.0 17 | target: wasm32-unknown-unknown 18 | override: true 19 | 20 | - name: Install wasm-pack 21 | run: | 22 | curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh 23 | export PATH="$HOME/.cargo/bin:$PATH" 24 | wasm-pack --version 25 | 26 | - name: Install Firefox 27 | uses: browser-actions/setup-firefox@v1 28 | 29 | - name: Build 30 | run: | 31 | cd adapter 32 | cargo build --target wasm32-unknown-unknown 33 | 34 | - name: Test 35 | run: | 36 | cd adapter 37 | wasm-pack test --firefox --headless 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /adapter/Cargo.lock 3 | /macros/Cargo.lock 4 | Cargo.lock 5 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 18.14.1 -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | edition = "2021" 3 | resolver = "2" 4 | 5 | members = ["adapter", "example", "macros"] 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | adapter/README.md -------------------------------------------------------------------------------- /adapter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "axum-cloudflare-adapter" 3 | version = "0.14.0" 4 | edition = "2021" 5 | authors = ["Logan Keenan"] 6 | description = "An adapter to easily run an Axum server in a Cloudflare worker." 7 | rust-version = "1.81.0" 8 | repository = "https://github.com/logankeenan/axum-cloudflare-adapter" 9 | license = "MIT" 10 | keywords = ["Cloudflare", "Axum", "WASM"] 11 | 12 | [lib] 13 | crate-type = ["cdylib", "lib"] 14 | 15 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 16 | 17 | [dependencies] 18 | axum = { version = "^0.8.1", default-features = false } 19 | worker = { version = "^0.5.0" } 20 | axum-wasm-macros = "^0.1.2" 21 | futures = "0.3.30" 22 | 23 | [dev-dependencies] 24 | wasm-bindgen-test = "^0.3.43" 25 | wasm-bindgen-futures = "^0.4.43" 26 | wasm-bindgen = "^0.2.93" 27 | tower-service = "^0.3.3" 28 | -------------------------------------------------------------------------------- /adapter/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Logan Keenan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /adapter/README.md: -------------------------------------------------------------------------------- 1 | # axum-cloudflare-adapter 2 | 3 | [![Crates.io](https://img.shields.io/crates/v/axum-cloudflare-adapter)](https://crates.io/crates/axum-cloudflare-adapter) 4 | 5 | An adapter to easily run an [Axum](https://github.com/tokio-rs/axum) server in a Cloudflare worker. 6 | 7 | ## Cloudflare workers perliminary native support for Axum on 0.0.21+ 8 | 9 | Axum support in workers-rs is enabled by the [http](https://github.com/cloudflare/workers-rs?tab=readme-ov-file#http-feature) feature in worker-rs. 10 | 11 | This is possible because both Axum and worker-rs http uses the same [http](https://docs.rs/http/latest/http/) crate. 12 | 13 | This adapter can be used as an easy way to migrate from the non http workers-rs version to the http version: 14 | 1. Do not change your current workers-rs project dependency on the non http version of workers-rs (keep the http flag disabled). 15 | 1. Add the dependency to this adapter. 16 | 2. Add a catch all route to the existing router: 17 | ```rust 18 | .or_else_any_method_async("/*catchall", |_, ctx| async move { 19 | ``` 20 | 3. Inside the catch all route, add an axum router like in the example bellow. 21 | 4. Start to incrementally migrate the paths one by one, from the old router to the axum router. 22 | 5. Once finished, drop the dependency on this adapter and enable the "http" flag on workers-rs. 23 | 6. If you have any issues you can ask for help on #rust-on-workers on discord or open an issue in workers-rs github. 24 | 25 | ## Usage 26 | 27 | ```rust 28 | use worker::*; 29 | use axum::{ 30 | response::{Html}, 31 | routing::get, 32 | Router as AxumRouter, 33 | extract::State, 34 | }; 35 | use axum_cloudflare_adapter::{to_axum_request, to_worker_response, wasm_compat, EnvWrapper}; 36 | use tower_service::Service; 37 | use std::ops::Deref; 38 | 39 | #[derive(Clone)] 40 | pub struct AxumState { 41 | pub env_wrapper: EnvWrapper, 42 | } 43 | 44 | #[wasm_compat] 45 | async fn index(State(state): State) -> Html<&'static str> { 46 | let env: &Env = state.env_wrapper.env.deref(); 47 | let worker_rs_version: Var = env.var("WORKERS_RS_VERSION").unwrap(); 48 | console_log!("WORKERS_RS_VERSION: {}", worker_rs_version.to_string()); 49 | Html("

Hello from Axum!

") 50 | } 51 | 52 | #[event(fetch)] 53 | pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result { 54 | let mut _router: AxumRouter = AxumRouter::new() 55 | .route("/", get(index)) 56 | .with_state(AxumState { 57 | env_wrapper: EnvWrapper::new(env), 58 | }); 59 | let axum_request = to_axum_request(req).await.unwrap(); 60 | let axum_response = _router.call(axum_request).await.unwrap(); 61 | let response = to_worker_response(axum_response).await.unwrap(); 62 | Ok(response) 63 | } 64 | ``` 65 | 66 | ## Running tests 67 | 68 | `cd adapter && wasm-pack test --firefox --headless` 69 | 70 | ## Building 71 | 72 | `cd adapter && cargo build --target wasm32-unknown-unknown` 73 | 74 | ## Example 75 | 76 | The `/example` directory contains a Cloudflare worker running an Axum sever 77 | -------------------------------------------------------------------------------- /adapter/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.81.0" 3 | targets = [ "wasm32-unknown-unknown" ] -------------------------------------------------------------------------------- /adapter/src/error.rs: -------------------------------------------------------------------------------- 1 | use axum::http::header::InvalidHeaderName; 2 | use axum::http::header::InvalidHeaderValue; 3 | use axum::http::header::ToStrError; 4 | use axum::http::method::InvalidMethod; 5 | use axum::http::uri::InvalidUri; 6 | use axum::http::Error as HttpError; 7 | use axum::Error as AxumError; 8 | use worker::Error as WorkerError; 9 | 10 | #[derive(Debug)] 11 | // #[non_exhaustive] 12 | pub enum Error { 13 | WorkerError(WorkerError), 14 | AxumError(AxumError), 15 | InvalidUri(InvalidUri), 16 | InvalidMethod(InvalidMethod), 17 | HttpError(HttpError), 18 | InvalidHeaderValue(InvalidHeaderValue), 19 | InvalidHeaderName(InvalidHeaderName), 20 | ToStrError(ToStrError), 21 | } 22 | 23 | impl From for Error { 24 | fn from(err: AxumError) -> Error { 25 | Error::AxumError(err) 26 | } 27 | } 28 | 29 | impl From for Error { 30 | fn from(err: ToStrError) -> Error { 31 | Error::ToStrError(err) 32 | } 33 | } 34 | 35 | impl From for Error { 36 | fn from(err: HttpError) -> Error { 37 | Error::HttpError(err) 38 | } 39 | } 40 | 41 | impl From for Error { 42 | fn from(err: InvalidMethod) -> Error { 43 | Error::InvalidMethod(err) 44 | } 45 | } 46 | 47 | impl From for Error { 48 | fn from(err: InvalidUri) -> Error { 49 | Error::InvalidUri(err) 50 | } 51 | } 52 | 53 | impl From for Error { 54 | fn from(err: WorkerError) -> Error { 55 | Error::WorkerError(err) 56 | } 57 | } 58 | 59 | impl From for Error { 60 | fn from(err: InvalidHeaderName) -> Error { 61 | Error::InvalidHeaderName(err) 62 | } 63 | } 64 | 65 | impl From for Error { 66 | fn from(err: InvalidHeaderValue) -> Error { 67 | Error::InvalidHeaderValue(err) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /adapter/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Axum Cloudflare Adapter 2 | //! 3 | //! A collection of tools allowing Axum to be run within a Cloudflare worker. See example usage below. 4 | //! 5 | 6 | //! ``` 7 | //! use worker::*; 8 | //! 9 | //! use axum::{ 10 | //! response::{Html}, 11 | //! routing::get, 12 | //! Router as AxumRouter, 13 | //! extract::State, 14 | //! }; 15 | //! use axum_cloudflare_adapter::{to_axum_request, to_worker_response, wasm_compat, EnvWrapper}; 16 | //! use tower_service::Service; 17 | //! use std::ops::Deref; 18 | //! 19 | //! #[derive(Clone)] 20 | //! pub struct AxumState { 21 | //! pub env_wrapper: EnvWrapper, 22 | //! } 23 | //! 24 | //! #[wasm_compat] 25 | //! async fn index(State(state): State) -> Html<&'static str> { 26 | //! let env: &Env = state.env_wrapper.env.deref(); 27 | //! let worker_rs_version: Var = env.var("WORKERS_RS_VERSION").unwrap(); 28 | //! console_log!("WORKERS_RS_VERSION: {}", worker_rs_version.to_string()); 29 | //! 30 | //! Html("

Hello from Axum!

") 31 | //! } 32 | //! 33 | //! #[event(fetch)] 34 | //! async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result { 35 | //! let mut router: AxumRouter = AxumRouter::new() 36 | //! .route("/", get(index)) 37 | //! .with_state(AxumState { 38 | //! env_wrapper: EnvWrapper::new(env), 39 | //! }); 40 | //! 41 | //! let axum_request = to_axum_request(req).await.unwrap(); 42 | //! let axum_response = router.call(axum_request).await.unwrap(); 43 | //! let response = to_worker_response(axum_response).await.unwrap(); 44 | //! 45 | //! Ok(response) 46 | //! } 47 | //! 48 | //! ``` 49 | mod error; 50 | 51 | use axum::{ 52 | body::Body, 53 | http::header::HeaderName, 54 | http::{Method, Request, Uri}, 55 | response::Response, 56 | }; 57 | pub use error::Error; 58 | use futures::TryStreamExt; 59 | use std::str::FromStr; 60 | use std::sync::Arc; 61 | use worker::{Headers, Request as WorkerRequest, Response as WorkerResponse}; 62 | 63 | pub async fn to_axum_request(mut worker_request: WorkerRequest) -> Result, Error> { 64 | let method = Method::from_bytes(worker_request.method().to_string().as_bytes())?; 65 | 66 | let uri = Uri::from_str(worker_request.url()?.to_string().as_str())?; 67 | 68 | let body = worker_request.bytes().await?; 69 | 70 | let mut http_request = Request::builder() 71 | .method(method) 72 | .uri(uri) 73 | .body(Body::from(body))?; 74 | 75 | for (header_name, header_value) in worker_request.headers() { 76 | http_request.headers_mut().insert( 77 | HeaderName::from_str(header_name.as_str())?, 78 | header_value.parse()?, 79 | ); 80 | } 81 | 82 | Ok(http_request) 83 | } 84 | 85 | pub async fn to_worker_response(response: Response) -> Result { 86 | let mut bytes: Vec = Vec::::new(); 87 | 88 | let (parts, body) = response.into_parts(); 89 | 90 | let mut stream = body.into_data_stream(); 91 | while let Some(chunk) = stream.try_next().await? { 92 | bytes.extend_from_slice(&chunk); 93 | } 94 | 95 | let code = parts.status.as_u16(); 96 | 97 | let mut worker_response = WorkerResponse::from_bytes(bytes)?; 98 | worker_response = worker_response.with_status(code); 99 | 100 | let mut headers = Headers::new(); 101 | for (key, value) in parts.headers.iter() { 102 | headers.set(key.as_str(), value.to_str()?).unwrap() 103 | } 104 | worker_response = worker_response.with_headers(headers); 105 | 106 | Ok(worker_response) 107 | } 108 | 109 | pub use axum_wasm_macros::wasm_compat; 110 | 111 | #[derive(Clone)] 112 | pub struct EnvWrapper { 113 | pub env: Arc, 114 | } 115 | 116 | impl EnvWrapper { 117 | pub fn new(env: worker::Env) -> Self { 118 | Self { env: Arc::new(env) } 119 | } 120 | } 121 | 122 | unsafe impl Send for EnvWrapper {} 123 | 124 | unsafe impl Sync for EnvWrapper {} 125 | 126 | #[cfg(test)] 127 | mod tests { 128 | use super::*; 129 | use axum::{response::Html, response::IntoResponse}; 130 | use wasm_bindgen_test::*; 131 | use worker::{Method as WorkerMethod, RequestInit, ResponseBody}; 132 | wasm_bindgen_test_configure!(run_in_browser); 133 | 134 | #[wasm_bindgen_test] 135 | async fn it_should_convert_the_worker_request_to_an_axum_request() { 136 | let mut request_init = RequestInit::new(); 137 | let mut headers = Headers::new(); 138 | headers.append("Content-Type", "text/html").unwrap(); 139 | headers.append("Cache-Control", "no-cache").unwrap(); 140 | request_init.with_headers(headers); 141 | request_init.with_method(WorkerMethod::Get); 142 | let worker_request = 143 | WorkerRequest::new_with_init("https://logankeenan.com", &request_init).unwrap(); 144 | 145 | let request = to_axum_request(worker_request).await.unwrap(); 146 | 147 | assert_eq!(request.uri(), "https://logankeenan.com"); 148 | assert_eq!(request.method(), "GET"); 149 | assert_eq!(request.headers().get("Content-Type").unwrap(), "text/html"); 150 | assert_eq!(request.headers().get("Cache-Control").unwrap(), "no-cache"); 151 | } 152 | 153 | #[wasm_bindgen_test] 154 | async fn it_should_convert_the_worker_request_to_an_axum_request_with_a_body() { 155 | let mut request_init = RequestInit::new(); 156 | request_init.with_body(Some("hello world!".into())); 157 | request_init.with_method(WorkerMethod::Post); 158 | let worker_request = 159 | WorkerRequest::new_with_init("https://logankeenan.com", &request_init).unwrap(); 160 | 161 | let request = to_axum_request(worker_request).await.unwrap(); 162 | 163 | let mut bytes: Vec = Vec::::new(); 164 | 165 | let mut stream = request.into_body().into_data_stream(); 166 | while let Some(chunk) = stream.try_next().await.unwrap() { 167 | bytes.extend_from_slice(&chunk); 168 | } 169 | 170 | assert_eq!(bytes.to_vec(), b"hello world!"); 171 | } 172 | 173 | #[wasm_bindgen_test] 174 | async fn it_should_convert_the_axum_response_to_a_worker_response() { 175 | let response = Html::from("Hello World!").into_response(); 176 | let worker_response = to_worker_response(response).await.unwrap(); 177 | 178 | assert_eq!(worker_response.status_code(), 200); 179 | assert_eq!( 180 | worker_response 181 | .headers() 182 | .get("Content-Type") 183 | .unwrap() 184 | .unwrap(), 185 | "text/html; charset=utf-8" 186 | ); 187 | let body = match worker_response.body() { 188 | ResponseBody::Body(body) => body.clone(), 189 | _ => vec![], 190 | }; 191 | assert_eq!(body, b"Hello World!"); 192 | } 193 | 194 | #[wasm_bindgen_test] 195 | async fn it_should_convert_the_axum_response_to_a_worker_response_with_an_empty_body() { 196 | let body = Body::empty(); 197 | let response = Response::builder() 198 | .status(200) 199 | .header("Content-Type", "text/html") 200 | .body(body) 201 | .unwrap(); 202 | 203 | let worker_response = to_worker_response(response).await.unwrap(); 204 | 205 | assert_eq!(worker_response.status_code(), 200); 206 | assert_eq!( 207 | worker_response 208 | .headers() 209 | .get("Content-Type") 210 | .unwrap() 211 | .unwrap(), 212 | "text/html" 213 | ); 214 | let body = match worker_response.body() { 215 | ResponseBody::Body(body) => body.clone(), 216 | _ => b"should be empty".to_vec(), 217 | }; 218 | assert_eq!(body.len(), 0); 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /example/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | tab_width = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.yml] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /node_modules 3 | 4 | **/*.rs.bk 5 | wasm-pack.log 6 | 7 | build/ 8 | /target 9 | /dist 10 | -------------------------------------------------------------------------------- /example/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.21.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "async-trait" 22 | version = "0.1.79" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" 25 | dependencies = [ 26 | "proc-macro2", 27 | "quote", 28 | "syn 2.0.55", 29 | ] 30 | 31 | [[package]] 32 | name = "autocfg" 33 | version = "1.1.0" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 36 | 37 | [[package]] 38 | name = "axum" 39 | version = "0.8.4" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" 42 | dependencies = [ 43 | "axum-core", 44 | "bytes", 45 | "futures-util", 46 | "http", 47 | "http-body", 48 | "http-body-util", 49 | "itoa", 50 | "matchit 0.8.4", 51 | "memchr", 52 | "mime", 53 | "percent-encoding", 54 | "pin-project-lite", 55 | "rustversion", 56 | "serde", 57 | "sync_wrapper", 58 | "tower", 59 | "tower-layer", 60 | "tower-service", 61 | ] 62 | 63 | [[package]] 64 | name = "axum-cloudflare-adapter" 65 | version = "0.14.0" 66 | dependencies = [ 67 | "axum", 68 | "axum-wasm-macros", 69 | "futures", 70 | "worker", 71 | ] 72 | 73 | [[package]] 74 | name = "axum-core" 75 | version = "0.5.2" 76 | source = "registry+https://github.com/rust-lang/crates.io-index" 77 | checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" 78 | dependencies = [ 79 | "bytes", 80 | "futures-core", 81 | "http", 82 | "http-body", 83 | "http-body-util", 84 | "mime", 85 | "pin-project-lite", 86 | "rustversion", 87 | "sync_wrapper", 88 | "tower-layer", 89 | "tower-service", 90 | ] 91 | 92 | [[package]] 93 | name = "axum-wasm-macros" 94 | version = "0.1.2" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "89e6832759c0999d93009d56f931e8bb454b78d2a73f999fe9c8caa21f7e7b22" 97 | dependencies = [ 98 | "quote", 99 | "syn 2.0.55", 100 | ] 101 | 102 | [[package]] 103 | name = "backtrace" 104 | version = "0.3.71" 105 | source = "registry+https://github.com/rust-lang/crates.io-index" 106 | checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" 107 | dependencies = [ 108 | "addr2line", 109 | "cc", 110 | "cfg-if", 111 | "libc", 112 | "miniz_oxide", 113 | "object", 114 | "rustc-demangle", 115 | ] 116 | 117 | [[package]] 118 | name = "bumpalo" 119 | version = "3.12.0" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" 122 | 123 | [[package]] 124 | name = "bytes" 125 | version = "1.6.0" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" 128 | 129 | [[package]] 130 | name = "cc" 131 | version = "1.0.90" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" 134 | 135 | [[package]] 136 | name = "cfg-if" 137 | version = "1.0.0" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 140 | 141 | [[package]] 142 | name = "chrono" 143 | version = "0.4.37" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" 146 | dependencies = [ 147 | "js-sys", 148 | "num-traits", 149 | "wasm-bindgen", 150 | ] 151 | 152 | [[package]] 153 | name = "console_error_panic_hook" 154 | version = "0.1.7" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" 157 | dependencies = [ 158 | "cfg-if", 159 | "wasm-bindgen", 160 | ] 161 | 162 | [[package]] 163 | name = "displaydoc" 164 | version = "0.2.5" 165 | source = "registry+https://github.com/rust-lang/crates.io-index" 166 | checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" 167 | dependencies = [ 168 | "proc-macro2", 169 | "quote", 170 | "syn 2.0.55", 171 | ] 172 | 173 | [[package]] 174 | name = "fnv" 175 | version = "1.0.7" 176 | source = "registry+https://github.com/rust-lang/crates.io-index" 177 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 178 | 179 | [[package]] 180 | name = "form_urlencoded" 181 | version = "1.2.1" 182 | source = "registry+https://github.com/rust-lang/crates.io-index" 183 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" 184 | dependencies = [ 185 | "percent-encoding", 186 | ] 187 | 188 | [[package]] 189 | name = "futures" 190 | version = "0.3.30" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" 193 | dependencies = [ 194 | "futures-channel", 195 | "futures-core", 196 | "futures-executor", 197 | "futures-io", 198 | "futures-sink", 199 | "futures-task", 200 | "futures-util", 201 | ] 202 | 203 | [[package]] 204 | name = "futures-channel" 205 | version = "0.3.30" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" 208 | dependencies = [ 209 | "futures-core", 210 | "futures-sink", 211 | ] 212 | 213 | [[package]] 214 | name = "futures-core" 215 | version = "0.3.30" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" 218 | 219 | [[package]] 220 | name = "futures-executor" 221 | version = "0.3.30" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" 224 | dependencies = [ 225 | "futures-core", 226 | "futures-task", 227 | "futures-util", 228 | ] 229 | 230 | [[package]] 231 | name = "futures-io" 232 | version = "0.3.30" 233 | source = "registry+https://github.com/rust-lang/crates.io-index" 234 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" 235 | 236 | [[package]] 237 | name = "futures-macro" 238 | version = "0.3.30" 239 | source = "registry+https://github.com/rust-lang/crates.io-index" 240 | checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" 241 | dependencies = [ 242 | "proc-macro2", 243 | "quote", 244 | "syn 2.0.55", 245 | ] 246 | 247 | [[package]] 248 | name = "futures-sink" 249 | version = "0.3.30" 250 | source = "registry+https://github.com/rust-lang/crates.io-index" 251 | checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" 252 | 253 | [[package]] 254 | name = "futures-task" 255 | version = "0.3.30" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" 258 | 259 | [[package]] 260 | name = "futures-util" 261 | version = "0.3.30" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" 264 | dependencies = [ 265 | "futures-channel", 266 | "futures-core", 267 | "futures-io", 268 | "futures-macro", 269 | "futures-sink", 270 | "futures-task", 271 | "memchr", 272 | "pin-project-lite", 273 | "pin-utils", 274 | "slab", 275 | ] 276 | 277 | [[package]] 278 | name = "gimli" 279 | version = "0.28.1" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" 282 | 283 | [[package]] 284 | name = "http" 285 | version = "1.1.0" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" 288 | dependencies = [ 289 | "bytes", 290 | "fnv", 291 | "itoa", 292 | ] 293 | 294 | [[package]] 295 | name = "http-body" 296 | version = "1.0.0" 297 | source = "registry+https://github.com/rust-lang/crates.io-index" 298 | checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" 299 | dependencies = [ 300 | "bytes", 301 | "http", 302 | ] 303 | 304 | [[package]] 305 | name = "http-body-util" 306 | version = "0.1.1" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" 309 | dependencies = [ 310 | "bytes", 311 | "futures-core", 312 | "http", 313 | "http-body", 314 | "pin-project-lite", 315 | ] 316 | 317 | [[package]] 318 | name = "icu_collections" 319 | version = "1.5.0" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" 322 | dependencies = [ 323 | "displaydoc", 324 | "yoke", 325 | "zerofrom", 326 | "zerovec", 327 | ] 328 | 329 | [[package]] 330 | name = "icu_locid" 331 | version = "1.5.0" 332 | source = "registry+https://github.com/rust-lang/crates.io-index" 333 | checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" 334 | dependencies = [ 335 | "displaydoc", 336 | "litemap", 337 | "tinystr", 338 | "writeable", 339 | "zerovec", 340 | ] 341 | 342 | [[package]] 343 | name = "icu_locid_transform" 344 | version = "1.5.0" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" 347 | dependencies = [ 348 | "displaydoc", 349 | "icu_locid", 350 | "icu_locid_transform_data", 351 | "icu_provider", 352 | "tinystr", 353 | "zerovec", 354 | ] 355 | 356 | [[package]] 357 | name = "icu_locid_transform_data" 358 | version = "1.5.0" 359 | source = "registry+https://github.com/rust-lang/crates.io-index" 360 | checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" 361 | 362 | [[package]] 363 | name = "icu_normalizer" 364 | version = "1.5.0" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" 367 | dependencies = [ 368 | "displaydoc", 369 | "icu_collections", 370 | "icu_normalizer_data", 371 | "icu_properties", 372 | "icu_provider", 373 | "smallvec", 374 | "utf16_iter", 375 | "utf8_iter", 376 | "write16", 377 | "zerovec", 378 | ] 379 | 380 | [[package]] 381 | name = "icu_normalizer_data" 382 | version = "1.5.0" 383 | source = "registry+https://github.com/rust-lang/crates.io-index" 384 | checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" 385 | 386 | [[package]] 387 | name = "icu_properties" 388 | version = "1.5.1" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" 391 | dependencies = [ 392 | "displaydoc", 393 | "icu_collections", 394 | "icu_locid_transform", 395 | "icu_properties_data", 396 | "icu_provider", 397 | "tinystr", 398 | "zerovec", 399 | ] 400 | 401 | [[package]] 402 | name = "icu_properties_data" 403 | version = "1.5.0" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" 406 | 407 | [[package]] 408 | name = "icu_provider" 409 | version = "1.5.0" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" 412 | dependencies = [ 413 | "displaydoc", 414 | "icu_locid", 415 | "icu_provider_macros", 416 | "stable_deref_trait", 417 | "tinystr", 418 | "writeable", 419 | "yoke", 420 | "zerofrom", 421 | "zerovec", 422 | ] 423 | 424 | [[package]] 425 | name = "icu_provider_macros" 426 | version = "1.5.0" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" 429 | dependencies = [ 430 | "proc-macro2", 431 | "quote", 432 | "syn 2.0.55", 433 | ] 434 | 435 | [[package]] 436 | name = "idna" 437 | version = "1.0.3" 438 | source = "registry+https://github.com/rust-lang/crates.io-index" 439 | checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" 440 | dependencies = [ 441 | "idna_adapter", 442 | "smallvec", 443 | "utf8_iter", 444 | ] 445 | 446 | [[package]] 447 | name = "idna_adapter" 448 | version = "1.2.0" 449 | source = "registry+https://github.com/rust-lang/crates.io-index" 450 | checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" 451 | dependencies = [ 452 | "icu_normalizer", 453 | "icu_properties", 454 | ] 455 | 456 | [[package]] 457 | name = "itoa" 458 | version = "1.0.5" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" 461 | 462 | [[package]] 463 | name = "js-sys" 464 | version = "0.3.70" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" 467 | dependencies = [ 468 | "wasm-bindgen", 469 | ] 470 | 471 | [[package]] 472 | name = "libc" 473 | version = "0.2.153" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 476 | 477 | [[package]] 478 | name = "litemap" 479 | version = "0.7.3" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" 482 | 483 | [[package]] 484 | name = "log" 485 | version = "0.4.17" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 488 | dependencies = [ 489 | "cfg-if", 490 | ] 491 | 492 | [[package]] 493 | name = "matchit" 494 | version = "0.7.0" 495 | source = "registry+https://github.com/rust-lang/crates.io-index" 496 | checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" 497 | 498 | [[package]] 499 | name = "matchit" 500 | version = "0.8.4" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" 503 | 504 | [[package]] 505 | name = "memchr" 506 | version = "2.5.0" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 509 | 510 | [[package]] 511 | name = "mime" 512 | version = "0.3.16" 513 | source = "registry+https://github.com/rust-lang/crates.io-index" 514 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 515 | 516 | [[package]] 517 | name = "miniz_oxide" 518 | version = "0.7.2" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" 521 | dependencies = [ 522 | "adler", 523 | ] 524 | 525 | [[package]] 526 | name = "num-traits" 527 | version = "0.2.15" 528 | source = "registry+https://github.com/rust-lang/crates.io-index" 529 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 530 | dependencies = [ 531 | "autocfg", 532 | ] 533 | 534 | [[package]] 535 | name = "object" 536 | version = "0.32.2" 537 | source = "registry+https://github.com/rust-lang/crates.io-index" 538 | checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" 539 | dependencies = [ 540 | "memchr", 541 | ] 542 | 543 | [[package]] 544 | name = "once_cell" 545 | version = "1.17.1" 546 | source = "registry+https://github.com/rust-lang/crates.io-index" 547 | checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" 548 | 549 | [[package]] 550 | name = "oneshot" 551 | version = "0.1.11" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "b4ce411919553d3f9fa53a0880544cda985a112117a0444d5ff1e870a893d6ea" 554 | 555 | [[package]] 556 | name = "percent-encoding" 557 | version = "2.3.1" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" 560 | 561 | [[package]] 562 | name = "pin-project" 563 | version = "1.1.5" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" 566 | dependencies = [ 567 | "pin-project-internal", 568 | ] 569 | 570 | [[package]] 571 | name = "pin-project-internal" 572 | version = "1.1.5" 573 | source = "registry+https://github.com/rust-lang/crates.io-index" 574 | checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" 575 | dependencies = [ 576 | "proc-macro2", 577 | "quote", 578 | "syn 2.0.55", 579 | ] 580 | 581 | [[package]] 582 | name = "pin-project-lite" 583 | version = "0.2.9" 584 | source = "registry+https://github.com/rust-lang/crates.io-index" 585 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 586 | 587 | [[package]] 588 | name = "pin-utils" 589 | version = "0.1.0" 590 | source = "registry+https://github.com/rust-lang/crates.io-index" 591 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 592 | 593 | [[package]] 594 | name = "proc-macro2" 595 | version = "1.0.79" 596 | source = "registry+https://github.com/rust-lang/crates.io-index" 597 | checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" 598 | dependencies = [ 599 | "unicode-ident", 600 | ] 601 | 602 | [[package]] 603 | name = "quote" 604 | version = "1.0.35" 605 | source = "registry+https://github.com/rust-lang/crates.io-index" 606 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" 607 | dependencies = [ 608 | "proc-macro2", 609 | ] 610 | 611 | [[package]] 612 | name = "rustc-demangle" 613 | version = "0.1.23" 614 | source = "registry+https://github.com/rust-lang/crates.io-index" 615 | checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" 616 | 617 | [[package]] 618 | name = "rustversion" 619 | version = "1.0.11" 620 | source = "registry+https://github.com/rust-lang/crates.io-index" 621 | checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" 622 | 623 | [[package]] 624 | name = "ryu" 625 | version = "1.0.12" 626 | source = "registry+https://github.com/rust-lang/crates.io-index" 627 | checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" 628 | 629 | [[package]] 630 | name = "serde" 631 | version = "1.0.197" 632 | source = "registry+https://github.com/rust-lang/crates.io-index" 633 | checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" 634 | dependencies = [ 635 | "serde_derive", 636 | ] 637 | 638 | [[package]] 639 | name = "serde-wasm-bindgen" 640 | version = "0.5.0" 641 | source = "registry+https://github.com/rust-lang/crates.io-index" 642 | checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" 643 | dependencies = [ 644 | "js-sys", 645 | "serde", 646 | "wasm-bindgen", 647 | ] 648 | 649 | [[package]] 650 | name = "serde-wasm-bindgen" 651 | version = "0.6.5" 652 | source = "registry+https://github.com/rust-lang/crates.io-index" 653 | checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" 654 | dependencies = [ 655 | "js-sys", 656 | "serde", 657 | "wasm-bindgen", 658 | ] 659 | 660 | [[package]] 661 | name = "serde_derive" 662 | version = "1.0.197" 663 | source = "registry+https://github.com/rust-lang/crates.io-index" 664 | checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" 665 | dependencies = [ 666 | "proc-macro2", 667 | "quote", 668 | "syn 2.0.55", 669 | ] 670 | 671 | [[package]] 672 | name = "serde_json" 673 | version = "1.0.140" 674 | source = "registry+https://github.com/rust-lang/crates.io-index" 675 | checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" 676 | dependencies = [ 677 | "itoa", 678 | "memchr", 679 | "ryu", 680 | "serde", 681 | ] 682 | 683 | [[package]] 684 | name = "serde_urlencoded" 685 | version = "0.7.1" 686 | source = "registry+https://github.com/rust-lang/crates.io-index" 687 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 688 | dependencies = [ 689 | "form_urlencoded", 690 | "itoa", 691 | "ryu", 692 | "serde", 693 | ] 694 | 695 | [[package]] 696 | name = "slab" 697 | version = "0.4.7" 698 | source = "registry+https://github.com/rust-lang/crates.io-index" 699 | checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" 700 | dependencies = [ 701 | "autocfg", 702 | ] 703 | 704 | [[package]] 705 | name = "smallvec" 706 | version = "1.13.2" 707 | source = "registry+https://github.com/rust-lang/crates.io-index" 708 | checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" 709 | 710 | [[package]] 711 | name = "stable_deref_trait" 712 | version = "1.2.0" 713 | source = "registry+https://github.com/rust-lang/crates.io-index" 714 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" 715 | 716 | [[package]] 717 | name = "syn" 718 | version = "1.0.107" 719 | source = "registry+https://github.com/rust-lang/crates.io-index" 720 | checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" 721 | dependencies = [ 722 | "proc-macro2", 723 | "quote", 724 | "unicode-ident", 725 | ] 726 | 727 | [[package]] 728 | name = "syn" 729 | version = "2.0.55" 730 | source = "registry+https://github.com/rust-lang/crates.io-index" 731 | checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" 732 | dependencies = [ 733 | "proc-macro2", 734 | "quote", 735 | "unicode-ident", 736 | ] 737 | 738 | [[package]] 739 | name = "sync_wrapper" 740 | version = "1.0.0" 741 | source = "registry+https://github.com/rust-lang/crates.io-index" 742 | checksum = "384595c11a4e2969895cad5a8c4029115f5ab956a9e5ef4de79d11a426e5f20c" 743 | 744 | [[package]] 745 | name = "synstructure" 746 | version = "0.13.1" 747 | source = "registry+https://github.com/rust-lang/crates.io-index" 748 | checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" 749 | dependencies = [ 750 | "proc-macro2", 751 | "quote", 752 | "syn 2.0.55", 753 | ] 754 | 755 | [[package]] 756 | name = "thiserror" 757 | version = "1.0.38" 758 | source = "registry+https://github.com/rust-lang/crates.io-index" 759 | checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" 760 | dependencies = [ 761 | "thiserror-impl", 762 | ] 763 | 764 | [[package]] 765 | name = "thiserror-impl" 766 | version = "1.0.38" 767 | source = "registry+https://github.com/rust-lang/crates.io-index" 768 | checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" 769 | dependencies = [ 770 | "proc-macro2", 771 | "quote", 772 | "syn 1.0.107", 773 | ] 774 | 775 | [[package]] 776 | name = "tinystr" 777 | version = "0.7.6" 778 | source = "registry+https://github.com/rust-lang/crates.io-index" 779 | checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" 780 | dependencies = [ 781 | "displaydoc", 782 | "zerovec", 783 | ] 784 | 785 | [[package]] 786 | name = "todo-worker" 787 | version = "0.0.0" 788 | dependencies = [ 789 | "axum", 790 | "axum-cloudflare-adapter", 791 | "cfg-if", 792 | "console_error_panic_hook", 793 | "oneshot", 794 | "serde_json", 795 | "tower-service", 796 | "url", 797 | "wasm-bindgen-futures", 798 | "worker", 799 | ] 800 | 801 | [[package]] 802 | name = "tokio" 803 | version = "1.29.1" 804 | source = "registry+https://github.com/rust-lang/crates.io-index" 805 | checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" 806 | dependencies = [ 807 | "autocfg", 808 | "backtrace", 809 | "pin-project-lite", 810 | ] 811 | 812 | [[package]] 813 | name = "tower" 814 | version = "0.5.2" 815 | source = "registry+https://github.com/rust-lang/crates.io-index" 816 | checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" 817 | dependencies = [ 818 | "futures-core", 819 | "futures-util", 820 | "pin-project-lite", 821 | "sync_wrapper", 822 | "tower-layer", 823 | "tower-service", 824 | ] 825 | 826 | [[package]] 827 | name = "tower-layer" 828 | version = "0.3.3" 829 | source = "registry+https://github.com/rust-lang/crates.io-index" 830 | checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" 831 | 832 | [[package]] 833 | name = "tower-service" 834 | version = "0.3.3" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" 837 | 838 | [[package]] 839 | name = "unicode-ident" 840 | version = "1.0.6" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" 843 | 844 | [[package]] 845 | name = "url" 846 | version = "2.5.4" 847 | source = "registry+https://github.com/rust-lang/crates.io-index" 848 | checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" 849 | dependencies = [ 850 | "form_urlencoded", 851 | "idna", 852 | "percent-encoding", 853 | ] 854 | 855 | [[package]] 856 | name = "utf16_iter" 857 | version = "1.0.5" 858 | source = "registry+https://github.com/rust-lang/crates.io-index" 859 | checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" 860 | 861 | [[package]] 862 | name = "utf8_iter" 863 | version = "1.0.4" 864 | source = "registry+https://github.com/rust-lang/crates.io-index" 865 | checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" 866 | 867 | [[package]] 868 | name = "wasm-bindgen" 869 | version = "0.2.93" 870 | source = "registry+https://github.com/rust-lang/crates.io-index" 871 | checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" 872 | dependencies = [ 873 | "cfg-if", 874 | "once_cell", 875 | "wasm-bindgen-macro", 876 | ] 877 | 878 | [[package]] 879 | name = "wasm-bindgen-backend" 880 | version = "0.2.93" 881 | source = "registry+https://github.com/rust-lang/crates.io-index" 882 | checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" 883 | dependencies = [ 884 | "bumpalo", 885 | "log", 886 | "once_cell", 887 | "proc-macro2", 888 | "quote", 889 | "syn 2.0.55", 890 | "wasm-bindgen-shared", 891 | ] 892 | 893 | [[package]] 894 | name = "wasm-bindgen-futures" 895 | version = "0.4.43" 896 | source = "registry+https://github.com/rust-lang/crates.io-index" 897 | checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" 898 | dependencies = [ 899 | "cfg-if", 900 | "js-sys", 901 | "wasm-bindgen", 902 | "web-sys", 903 | ] 904 | 905 | [[package]] 906 | name = "wasm-bindgen-macro" 907 | version = "0.2.93" 908 | source = "registry+https://github.com/rust-lang/crates.io-index" 909 | checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" 910 | dependencies = [ 911 | "quote", 912 | "wasm-bindgen-macro-support", 913 | ] 914 | 915 | [[package]] 916 | name = "wasm-bindgen-macro-support" 917 | version = "0.2.93" 918 | source = "registry+https://github.com/rust-lang/crates.io-index" 919 | checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" 920 | dependencies = [ 921 | "proc-macro2", 922 | "quote", 923 | "syn 2.0.55", 924 | "wasm-bindgen-backend", 925 | "wasm-bindgen-shared", 926 | ] 927 | 928 | [[package]] 929 | name = "wasm-bindgen-shared" 930 | version = "0.2.93" 931 | source = "registry+https://github.com/rust-lang/crates.io-index" 932 | checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" 933 | 934 | [[package]] 935 | name = "wasm-streams" 936 | version = "0.4.0" 937 | source = "registry+https://github.com/rust-lang/crates.io-index" 938 | checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" 939 | dependencies = [ 940 | "futures-util", 941 | "js-sys", 942 | "wasm-bindgen", 943 | "wasm-bindgen-futures", 944 | "web-sys", 945 | ] 946 | 947 | [[package]] 948 | name = "web-sys" 949 | version = "0.3.70" 950 | source = "registry+https://github.com/rust-lang/crates.io-index" 951 | checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" 952 | dependencies = [ 953 | "js-sys", 954 | "wasm-bindgen", 955 | ] 956 | 957 | [[package]] 958 | name = "worker" 959 | version = "0.5.0" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "727789ca7eff9733efbea9d0e97779edc1cf1926e98aee7d7d8afe32805458aa" 962 | dependencies = [ 963 | "async-trait", 964 | "bytes", 965 | "chrono", 966 | "futures-channel", 967 | "futures-util", 968 | "http", 969 | "http-body", 970 | "js-sys", 971 | "matchit 0.7.0", 972 | "pin-project", 973 | "serde", 974 | "serde-wasm-bindgen 0.6.5", 975 | "serde_json", 976 | "serde_urlencoded", 977 | "tokio", 978 | "url", 979 | "wasm-bindgen", 980 | "wasm-bindgen-futures", 981 | "wasm-streams", 982 | "web-sys", 983 | "worker-kv", 984 | "worker-macros", 985 | "worker-sys", 986 | ] 987 | 988 | [[package]] 989 | name = "worker-kv" 990 | version = "0.7.0" 991 | source = "registry+https://github.com/rust-lang/crates.io-index" 992 | checksum = "7f06d4d1416a9f8346ee9123b0d9a11b3cfa38e6cfb5a139698017d1597c4d41" 993 | dependencies = [ 994 | "js-sys", 995 | "serde", 996 | "serde-wasm-bindgen 0.5.0", 997 | "serde_json", 998 | "thiserror", 999 | "wasm-bindgen", 1000 | "wasm-bindgen-futures", 1001 | ] 1002 | 1003 | [[package]] 1004 | name = "worker-macros" 1005 | version = "0.5.0" 1006 | source = "registry+https://github.com/rust-lang/crates.io-index" 1007 | checksum = "7d625c24570ba9207a2617476013335f28a95cbe513e59bb814ffba092a18058" 1008 | dependencies = [ 1009 | "async-trait", 1010 | "proc-macro2", 1011 | "quote", 1012 | "syn 2.0.55", 1013 | "wasm-bindgen", 1014 | "wasm-bindgen-futures", 1015 | "wasm-bindgen-macro-support", 1016 | "worker-sys", 1017 | ] 1018 | 1019 | [[package]] 1020 | name = "worker-sys" 1021 | version = "0.5.0" 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" 1023 | checksum = "34563340d41016b4381257c5a16b0d2bc590dbe00500ecfbebcaa16f5f85ce90" 1024 | dependencies = [ 1025 | "cfg-if", 1026 | "js-sys", 1027 | "wasm-bindgen", 1028 | "web-sys", 1029 | ] 1030 | 1031 | [[package]] 1032 | name = "write16" 1033 | version = "1.0.0" 1034 | source = "registry+https://github.com/rust-lang/crates.io-index" 1035 | checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" 1036 | 1037 | [[package]] 1038 | name = "writeable" 1039 | version = "0.5.5" 1040 | source = "registry+https://github.com/rust-lang/crates.io-index" 1041 | checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" 1042 | 1043 | [[package]] 1044 | name = "yoke" 1045 | version = "0.7.4" 1046 | source = "registry+https://github.com/rust-lang/crates.io-index" 1047 | checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" 1048 | dependencies = [ 1049 | "serde", 1050 | "stable_deref_trait", 1051 | "yoke-derive", 1052 | "zerofrom", 1053 | ] 1054 | 1055 | [[package]] 1056 | name = "yoke-derive" 1057 | version = "0.7.4" 1058 | source = "registry+https://github.com/rust-lang/crates.io-index" 1059 | checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" 1060 | dependencies = [ 1061 | "proc-macro2", 1062 | "quote", 1063 | "syn 2.0.55", 1064 | "synstructure", 1065 | ] 1066 | 1067 | [[package]] 1068 | name = "zerofrom" 1069 | version = "0.1.4" 1070 | source = "registry+https://github.com/rust-lang/crates.io-index" 1071 | checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" 1072 | dependencies = [ 1073 | "zerofrom-derive", 1074 | ] 1075 | 1076 | [[package]] 1077 | name = "zerofrom-derive" 1078 | version = "0.1.4" 1079 | source = "registry+https://github.com/rust-lang/crates.io-index" 1080 | checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" 1081 | dependencies = [ 1082 | "proc-macro2", 1083 | "quote", 1084 | "syn 2.0.55", 1085 | "synstructure", 1086 | ] 1087 | 1088 | [[package]] 1089 | name = "zerovec" 1090 | version = "0.10.4" 1091 | source = "registry+https://github.com/rust-lang/crates.io-index" 1092 | checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" 1093 | dependencies = [ 1094 | "yoke", 1095 | "zerofrom", 1096 | "zerovec-derive", 1097 | ] 1098 | 1099 | [[package]] 1100 | name = "zerovec-derive" 1101 | version = "0.10.3" 1102 | source = "registry+https://github.com/rust-lang/crates.io-index" 1103 | checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" 1104 | dependencies = [ 1105 | "proc-macro2", 1106 | "quote", 1107 | "syn 2.0.55", 1108 | ] 1109 | -------------------------------------------------------------------------------- /example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "todo-worker" 3 | version = "0.0.0" 4 | edition = "2021" 5 | rust-version = "1.81.0" 6 | 7 | [lib] 8 | crate-type = ["cdylib", "rlib"] 9 | 10 | [features] 11 | default = ["console_error_panic_hook"] 12 | 13 | [dependencies] 14 | cfg-if = "1.0.0" 15 | axum = { version = "^0.8.4", default-features = false } 16 | axum-cloudflare-adapter = { path = "../adapter" } 17 | oneshot = "0.1.11" 18 | serde_json = "1.0.140" 19 | tower-service = "0.3.3" 20 | url = "2.5.4" 21 | wasm-bindgen-futures = "0.4.43" 22 | worker = "^0.5.0" 23 | 24 | # The `console_error_panic_hook` crate provides better debugging of panics by 25 | # logging them with `console.error`. This is great for development, but requires 26 | # all the `std::fmt` and `std::panicking` infrastructure, so isn't great for 27 | # code size when deploying. 28 | console_error_panic_hook = { version = "0.1.7", optional = true } 29 | 30 | [profile.release] 31 | # Tell `rustc` to optimize for small code size. 32 | opt-level = "s" 33 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # axum-cloudflare-adapter Demo 2 | 3 | A simple [demo](https://axum-cloudflare-adapter-example.logankeenan.workers.dev) to test out the features of axum-cloudflare-adapter 4 | 5 | 6 | ## Worker Commands 7 | ```sh 8 | # compiles your project to WebAssembly and will warn of any issues 9 | $ npm run build 10 | 11 | # run your Worker in an ideal development workflow (with a local server, file watcher & more) 12 | $ npm run dev 13 | 14 | # deploy your Worker globally to the Cloudflare network (update your wrangler.toml file for configuration) 15 | $ npm run deploy 16 | ``` 17 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "version": "0.0.0", 4 | "scripts": { 5 | "deploy": "wrangler publish", 6 | "dev": "wrangler dev --local" 7 | }, 8 | "devDependencies": { 9 | "wrangler": "^2.0.0" 10 | } 11 | } -------------------------------------------------------------------------------- /example/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "1.81.0" 3 | targets = [ "wasm32-unknown-unknown" ] -------------------------------------------------------------------------------- /example/src/lib.rs: -------------------------------------------------------------------------------- 1 | use axum::http::header::CONTENT_TYPE; 2 | use axum::{ 3 | extract::{Path, State}, 4 | response::IntoResponse, 5 | routing::get, 6 | Router as AxumRouter, 7 | }; 8 | use axum_cloudflare_adapter::{to_axum_request, to_worker_response, wasm_compat, EnvWrapper}; 9 | use std::ops::Deref; 10 | use std::str::FromStr; 11 | use tower_service::Service; 12 | use worker::{console_log, event, Date, Env, Request, Response, Result, Var}; 13 | 14 | mod utils; 15 | 16 | fn log_request(req: &Request) { 17 | if let Some(cf) = req.cf() { 18 | console_log!( 19 | "{} - [{}], located at: {:?}, within: {}", 20 | Date::now().to_string(), 21 | req.path(), 22 | cf.coordinates().unwrap_or_default(), 23 | cf.region().unwrap_or_else(|| "unknown region".into()) 24 | ); 25 | } else { 26 | console_log!( 27 | "{} - [{}], from unknown location", 28 | Date::now().to_string(), 29 | req.path(), 30 | ); 31 | } 32 | } 33 | 34 | use url::Url; 35 | 36 | #[wasm_compat] 37 | pub async fn index(State(state): State) -> impl IntoResponse { 38 | let url = Url::from_str("https://logankeenan.com").unwrap(); 39 | let mut response = worker::Fetch::Url(url).send().await.unwrap(); 40 | let body_text = response.text().await.unwrap(); 41 | 42 | let env: &Env = state.env_wrapper.env.deref(); 43 | let worker_rs_version: Var = env.var("WORKERS_RS_VERSION").unwrap(); 44 | 45 | console_log!("WORKERS_RS_VERSION: {}", worker_rs_version.to_string()); 46 | 47 | let content_type = response.headers().get("content-type").unwrap().unwrap(); 48 | axum::response::Response::builder() 49 | .header(CONTENT_TYPE, content_type) 50 | .body(body_text) 51 | .unwrap() 52 | } 53 | 54 | #[wasm_compat] 55 | pub async fn with_pathname(Path(path): Path) -> impl IntoResponse { 56 | let mut url = Url::from_str("https://logankeenan.com").unwrap(); 57 | url.set_path(path.as_str()); 58 | let mut response = worker::Fetch::Url(url).send().await.unwrap(); 59 | let body_text = response.text().await.unwrap(); 60 | 61 | let content_type = response.headers().get("content-type").unwrap().unwrap(); 62 | axum::response::Response::builder() 63 | .header(CONTENT_TYPE, content_type) 64 | .body(body_text) 65 | .unwrap() 66 | } 67 | 68 | #[derive(Clone)] 69 | pub struct AxumState { 70 | pub env_wrapper: EnvWrapper, 71 | } 72 | 73 | #[event(fetch)] 74 | pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result { 75 | log_request(&req); 76 | // Optionally, get more helpful error messages written to the console in the case of a panic. 77 | utils::set_panic_hook(); 78 | 79 | let axum_state = AxumState { 80 | env_wrapper: EnvWrapper::new(env), 81 | }; 82 | 83 | let mut _router: AxumRouter = AxumRouter::new() 84 | .route("/", get(index)) 85 | .route("/*path", get(with_pathname)) 86 | .with_state(axum_state); 87 | 88 | let axum_request = to_axum_request(req).await.unwrap(); 89 | let axum_response = _router.call(axum_request).await.unwrap(); 90 | let response = to_worker_response(axum_response).await.unwrap(); 91 | 92 | Ok(response) 93 | } 94 | -------------------------------------------------------------------------------- /example/src/utils.rs: -------------------------------------------------------------------------------- 1 | use cfg_if::cfg_if; 2 | 3 | cfg_if! { 4 | // https://github.com/rustwasm/console_error_panic_hook#readme 5 | if #[cfg(feature = "console_error_panic_hook")] { 6 | extern crate console_error_panic_hook; 7 | pub use self::console_error_panic_hook::set_once as set_panic_hook; 8 | } else { 9 | #[inline] 10 | pub fn set_panic_hook() {} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/wrangler.toml: -------------------------------------------------------------------------------- 1 | workers_dev = true 2 | compatibility_date = "2024-09-22" 3 | 4 | main = "build/worker/shim.mjs" 5 | name = "axum-cloudflare-adapter" 6 | 7 | [vars] 8 | WORKERS_RS_VERSION = "0.5.0" 9 | 10 | [build] 11 | command = "cargo install -q worker-build && worker-build --release" 12 | -------------------------------------------------------------------------------- /macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "axum-cloudflare-adapter-macros" 3 | version = "0.2.0" 4 | edition = "2021" 5 | authors = ["Logan Keenan"] 6 | description = "DEPRECEATED: use axum-wasm-macros" 7 | rust-version = "1.63" 8 | repository = "https://github.com/logankeenan/axum-cloudflare-adapter" 9 | license = "MIT" 10 | keywords = ["Cloudflare", "Axum", "WASM"] 11 | 12 | [lib] 13 | proc-macro = true 14 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 15 | 16 | [dependencies] 17 | -------------------------------------------------------------------------------- /macros/readme.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED - axum-cloudflare-adapter-macros 2 | 3 | This repository has been deprecated in favor of [axum-wasm-macros](https://crates.io/crates/axum-wasm-macros) -------------------------------------------------------------------------------- /macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------