{"id":18806939,"url":"https://github.com/chenzhiguo/rust-worker-demo","last_synced_at":"2026-01-08T21:30:29.923Z","repository":{"id":213152300,"uuid":"732943449","full_name":"chenzhiguo/rust-worker-demo","owner":"chenzhiguo","description":"A worker demo for cloudflare by rust.","archived":false,"fork":false,"pushed_at":"2023-12-18T17:06:57.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T21:28:33.181Z","etag":null,"topics":["cloudfare","rust","worker"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenzhiguo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-18T08:05:19.000Z","updated_at":"2023-12-18T08:07:25.000Z","dependencies_parsed_at":"2023-12-18T23:04:12.279Z","dependency_job_id":"89a487ec-f0e7-449c-9f9f-a3f4227d17fc","html_url":"https://github.com/chenzhiguo/rust-worker-demo","commit_stats":null,"previous_names":["chenzhiguo/rust-worker-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenzhiguo%2Frust-worker-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenzhiguo%2Frust-worker-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenzhiguo%2Frust-worker-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenzhiguo%2Frust-worker-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenzhiguo","download_url":"https://codeload.github.com/chenzhiguo/rust-worker-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239742417,"owners_count":19689309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudfare","rust","worker"],"created_at":"2024-11-07T22:50:03.225Z","updated_at":"2026-01-08T21:30:24.638Z","avatar_url":"https://github.com/chenzhiguo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Template: worker-rust\n\n[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/templates/tree/main/worker-rust)\n\nA template for kick starting a Cloudflare worker project using [`workers-rs`](https://github.com/cloudflare/workers-rs).\n\nThis template is designed for compiling Rust to WebAssembly and publishing the resulting worker to Cloudflare's [edge infrastructure](https://www.cloudflare.com/network/).\n\n## Setup\n\nTo create a `my-project` directory using this template, run:\n\n```sh\n$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-rust\n# or\n$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-rust\n# or\n$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-rust\n```\n\n## Wrangler\n\nWrangler is used to develop, deploy, and configure your Worker via CLI.\n\nFurther documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).\n\n## Usage\n\nThis template starts you off with a `src/lib.rs` file, acting as an entrypoint for requests hitting your Worker. Feel free to add more code in this file, or create Rust modules anywhere else for this project to use.\n\nWith `wrangler`, you can build, test, and deploy your Worker with the following commands:\n\n```sh\n# run your Worker in an ideal development workflow (with a local server, file watcher \u0026 more)\n$ npm run dev\n\n# deploy your Worker globally to the Cloudflare network (update your wrangler.toml file for configuration)\n$ npm run deploy\n```\n\nRead the latest `worker` crate documentation here: https://docs.rs/worker\n\n## Advanced Example\n\nAs this template comprises only the essential setup, we recommend considering our advanced example to leverage its additional functionalities. The advanced example showcases the creation of multiple routes, logging of requests, retrieval of field data from a form, and other features that may prove useful to your project.  \nThe following example has been taken from: [workers-rs](https://github.com/cloudflare/workers-rs). You can learn more about how to use workers with rust by going there.\n\n```rust\nuse worker::*;\n\n#[event(fetch)]\npub async fn main(req: Request, env: Env, _ctx: worker::Context) -\u003e Result\u003cResponse\u003e {\n    console_log!(\n        \"{} {}, located at: {:?}, within: {}\",\n        req.method().to_string(),\n        req.path(),\n        req.cf().coordinates().unwrap_or_default(),\n        req.cf().region().unwrap_or(\"unknown region\".into())\n    );\n\n    if !matches!(req.method(), Method::Post) {\n        return Response::error(\"Method Not Allowed\", 405);\n    }\n\n    if let Some(file) = req.form_data().await?.get(\"file\") {\n        return match file {\n            FormEntry::File(buf) =\u003e {\n                Response::ok(\u0026format!(\"size = {}\", buf.bytes().await?.len()))\n            }\n            _ =\u003e Response::error(\"`file` part of POST form must be a file\", 400),\n        };\n    }\n\n    Response::error(\"Bad Request\", 400)\n}\n```\n\n## WebAssembly\n\n`workers-rs` (the Rust SDK for Cloudflare Workers used in this template) is meant to be executed as compiled WebAssembly, and as such so **must** all the code you write and depend upon. All crates and modules used in Rust-based Workers projects have to compile to the `wasm32-unknown-unknown` triple.\n\nRead more about this on the [`workers-rs`](https://github.com/cloudflare/workers-rs) project README.\n\n## Issues\n\nIf you have any problems with the `worker` crate, please open an issue on the upstream project issue tracker on the [`workers-rs` repository](https://github.com/cloudflare/workers-rs).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenzhiguo%2Frust-worker-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenzhiguo%2Frust-worker-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenzhiguo%2Frust-worker-demo/lists"}