Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new fetch bindings to the rust kit #171

Merged
merged 4 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 67 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ members = [
exclude = [
"examples/pdf-create",
"examples/rust-basic",
"examples/rust-fetch",
"examples/rust-kv",
"examples/rust-params"
]
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/languages/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ In this example, the worker will get a request and print all the related informa

[dependencies]
anyhow = "1.0.63"
wasm-workers-rs = { git = "https://github.com/vmware-labs/wasm-workers-server/" }
wasm-workers-rs = { git = "https://github.com/vmware-labs/wasm-workers-server/", branch = "v1.3" }
```

1. Add the `reply` function to the `src/main.rs` file. You will need to import the required resources from the `wasm-workers-rs` crate and use the `worker` macro:
Expand Down Expand Up @@ -136,7 +136,7 @@ To add a KV store to your worker, follow these steps:

[dependencies]
anyhow = "1.0.63"
wasm-workers-rs = { git = "https://github.com/vmware-labs/wasm-workers-server/" }
wasm-workers-rs = { git = "https://github.com/vmware-labs/wasm-workers-server/", branch = "v1.3" }
```

1. Add the `reply` function to the `src/main.rs` file. You will need to import the required resources from the `wasm-workers-rs` crate and use the `worker` macro. In this case, we will add a new attribute to the `worker` macro called `cache` and update the function signature:
Expand Down Expand Up @@ -317,4 +317,4 @@ If you prefer, you can configure the environment variable value dynamically by f
## Other examples

* [Basic](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/rust-basic)
* [Counter](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/rust-kv)
* [Counter](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/rust-kv)
7 changes: 6 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ rust-basic:
cargo build --target wasm32-wasi --release && \
cp target/wasm32-wasi/release/rust-basic.wasm ./basic.wasm

rust-fetch:
cd rust-fetch && \
cargo build --target wasm32-wasi --release && \
cp target/wasm32-wasi/release/rust-fetch.wasm ./index.wasm

rust-kv:
cd rust-kv && \
cargo build --target wasm32-wasi --release && \
Expand All @@ -20,4 +25,4 @@ rust-pdf-create:
cargo build --target wasm32-wasi --release && \
mv target/wasm32-wasi/release/rust-pdf-create.wasm ./index.wasm

all: rust-basic rust-kv rust-params
all: rust-basic rust-fetch rust-kv rust-params
Loading